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/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/textWithTone/TextWithTone.tsx | import styled, {css} from 'styled-components'
import {ButtonTone, Text} from '@sanity/ui'
import React, {ComponentProps} from 'react'
/** @internal */
export interface TextWithToneProps extends ComponentProps<typeof Text> {
tone: ButtonTone
dimmed?: boolean
}
/** @internal */
const TextWithToneStyle = styled(Text... | 2,800 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/textWithTone/index.ts | export * from './TextWithTone'
| 2,801 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/textWithTone | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/textWithTone/__workshop__/TextWithToneStory.tsx | import {InfoOutlineIcon} from '@sanity/icons'
import {Box, Card, Flex, Grid, Stack} from '@sanity/ui'
import {useBoolean, useSelect} from '@sanity/ui-workshop'
import React from 'react'
import {TextWithTone} from '../TextWithTone'
const TEXT_SIZE_OPTIONS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
const CARD_TONE_OPTI... | 2,802 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/textWithTone | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/textWithTone/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/text-with-tone',
title: 'TextWithTone',
stories: [
{
name: 'default',
title: 'Default',
component: lazy(() => import('./TextWithToneStory')),
},
],
})
| 2,803 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/transitional/ImperativeToast.ts | import {useToast} from '@sanity/ui'
import React, {forwardRef, useImperativeHandle} from 'react'
/** @internal */
export interface ToastParams {
closable?: boolean
description?: React.ReactNode
duration?: number
onClose?: () => void
title?: React.ReactNode
status?: 'error' | 'warning' | 'success' | 'info'
... | 2,804 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/transitional/LegacyLayerProvider.tsx | import {LayerProvider} from '@sanity/ui'
import React from 'react'
import {useZIndex} from '../zOffsets/useZIndex'
import {ZIndexContextValue} from '../zOffsets/types'
/** @internal */
export type ZIndexContextValueKey = keyof ZIndexContextValue
/**
* This component should only be used by core Sanity packages.
* @i... | 2,805 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/transitional/index.ts | export * from './ImperativeToast'
export * from './LegacyLayerProvider'
| 2,806 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/userAvatar/UserAvatar.tsx | import {Avatar, AvatarPosition, AvatarSize, AvatarStatus, Box, Text, Tooltip} from '@sanity/ui'
import React, {forwardRef, useState} from 'react'
import type {User} from '@sanity/types'
import {useUser} from '../../store'
import {isRecord} from '../../util'
import {useUserColor} from '../../user-color'
/**
* @hidden
... | 2,807 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/userAvatar/index.ts | export * from './UserAvatar'
| 2,808 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/userAvatar | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/userAvatar/__workshop__/UserAvatarStory.tsx | import {AvatarSize, Flex} from '@sanity/ui'
import {useBoolean, useSelect} from '@sanity/ui-workshop'
import React from 'react'
import {UserAvatar} from '../UserAvatar'
const SIZE_OPTIONS: Record<string, AvatarSize> = {
'0': 0,
'1': 1,
'2': 2,
}
export default function UserAvatarStory() {
const size = useSele... | 2,809 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/userAvatar | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/userAvatar/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/user-avatar',
title: 'UserAvatar',
stories: [
{
name: 'user-avatar',
title: 'Default',
component: lazy(() => import('./UserAvatarStory')),
},
],
})
| 2,810 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/zOffsets/ZIndexContext.ts | import {createContext} from 'react'
import {ZIndexContextValue} from './types'
import {defaults} from './defaults'
/**
* TODO: Rename to `ZOffsetsContext`
*
* @internal
*/
export const ZIndexContext = createContext<ZIndexContextValue>(defaults)
| 2,811 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/zOffsets/ZIndexProvider.tsx | import React from 'react'
import {defaults} from './defaults'
import {ZIndexContext} from './ZIndexContext'
/**
* TODO: Rename to `ZOffsetsProvider`
*
* @internal
*/
export function ZIndexProvider({children}: {children?: React.ReactNode}): React.ReactElement {
return <ZIndexContext.Provider value={defaults}>{chi... | 2,812 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/zOffsets/defaults.ts | import {ZIndexContextValue} from './types'
/**
* @internal
*/
export const defaults: ZIndexContextValue = {
navbar: 200,
navbarPopover: 500000,
navbarDialog: 500001,
// pane
pane: 100,
paneHeader: [110, 15000],
paneFooter: [120, 20000],
paneResizer: [130, 25000],
//
popover: 200,
modal: 200,
... | 2,813 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/zOffsets/index.ts | export * from './types'
export * from './ZIndexProvider'
export * from './useZIndex'
| 2,814 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/zOffsets/types.ts | /**
* TODO: Rename to `ZOffsetsContextValue`
*
* @internal
*/
export interface ZIndexContextValue {
/** Used by: Navbar */
navbar: number | number[]
navbarPopover: number | number[]
navbarDialog: number | number[]
/** Used by: DefaultPane, DocumentPane */
pane: number | number[]
paneHeader: number | ... | 2,815 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/zOffsets/useZIndex.ts | import {useContext} from 'react'
import {ZIndexContextValue} from './types'
import {ZIndexContext} from './ZIndexContext'
/**
* TODO: Rename to `useZOffsets`
*
* @internal
*/
export function useZIndex(): ZIndexContextValue {
return useContext(ZIndexContext)
}
| 2,816 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/ConfigPropertyError.ts | import {isRecord} from '../util'
/** @internal */
export interface ConfigPropertyErrorOptions {
propertyName: string
path: string[]
cause: unknown
}
/** @internal */
export class ConfigPropertyError extends Error {
propertyName: string
path: string[]
cause: unknown
constructor({propertyName, path, caus... | 2,817 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/ConfigResolutionError.ts | import {isRecord} from '../util'
/** @internal */
export interface ConfigResolutionErrorOptions {
name: string
type: string
causes: Array<ConfigResolutionError | Error | unknown>
}
/** @internal */
export class ConfigResolutionError extends Error {
name: string
type: string
causes: unknown[]
constructo... | 2,818 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/SchemaError.ts | import {Schema} from '@sanity/types'
/** @internal */
// TODO: consider removing this error in favor of the `ConfigResolutionError`
export class SchemaError extends Error {
constructor(public schema: Schema) {
super('SchemaError')
}
}
| 2,819 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/configPropertyReducers.ts | import type {AssetSource, SchemaTypeDefinition} from '@sanity/types'
import {getPrintableType} from '../util/getPrintableType'
import type {Template, TemplateItem} from '../templates'
import type {DocumentActionComponent, DocumentBadgeComponent, DocumentInspector} from './document'
import type {
DocumentLanguageFilte... | 2,820 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/createDefaultIcon.tsx | import React from 'react'
import styled from 'styled-components'
import {COLOR_HUES, hues} from '@sanity/color'
import {darken, lighten, hasBadContrast, readableColor} from 'color2k'
function pseudoRandomNumber(seed: string) {
const hashCode = seed
.split('')
// eslint-disable-next-line no-bitwise
.reduc... | 2,821 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/defineConfig.ts | import type {Config} from './types'
/**
* @hidden
* @beta */
export function defineConfig<T extends Config>(config: T): T {
return config
}
/**
* @deprecated Use `defineConfig` instead
*
* @hidden
* @beta
*/
export function createConfig<T extends Config>(config: T): T {
return defineConfig(config)
}
| 2,822 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/definePlugin.ts | import {isString} from 'lodash'
import {Plugin, PluginOptions} from './types'
/**
* @hidden
* @beta */
export type PluginFactory<TOptions> = (options: TOptions) => PluginOptions
function validatePlugin(pluginResult: PluginOptions) {
// TODO: name is required etc
const messages = [
'projectId' in pluginResul... | 2,823 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/flattenConfig.ts | import {PluginOptions} from './types'
/**
* @internal
*
* This function flattens the config tree into a list of configs in the order they should be applied.
*/
export const flattenConfig = (
{plugins = [], ...currentConfig}: PluginOptions,
path: string[],
): Array<{config: PluginOptions; path: string[]}> => {
... | 2,824 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/index.ts | export * from './defineConfig'
export * from './definePlugin'
export * from './document'
export * from './types'
export * from './prepareConfig'
export * from './resolveConfig'
export * from './ConfigPropertyError'
export * from './ConfigResolutionError'
export * from './SchemaError'
export * from './useConfigContextFr... | 2,825 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/prepareConfig.ts | import {createClient, type SanityClient} from '@sanity/client'
import {map, shareReplay} from 'rxjs/operators'
import type {CurrentUser, Schema, SchemaValidationProblem} from '@sanity/types'
import {studioTheme} from '@sanity/ui'
import {startCase} from 'lodash'
import {fromUrl} from '@sanity/bifur-client'
import {crea... | 2,826 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/resolveConfig.ts | import {combineLatest, firstValueFrom, Observable} from 'rxjs'
import {map} from 'rxjs/operators'
import {CurrentUser} from '@sanity/types'
import {SanityClient} from '@sanity/client'
import {createMockAuthStore} from '../store'
import {Config, SingleWorkspace, Source, Workspace, SchemaPluginOptions} from './types'
imp... | 2,827 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/resolveConfigProperty.ts | import {ConfigPropertyError} from './ConfigPropertyError'
import {flattenConfig} from './flattenConfig'
import {PluginOptions, ConfigPropertyReducer, AsyncConfigPropertyReducer} from './types'
interface ResolveConfigPropertyOptions<TValue, TContext> {
propertyName: string
config: PluginOptions
context: TContext
... | 2,828 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/types.ts | import type {BifurClient} from '@sanity/bifur-client'
import type {ClientConfig as SanityClientConfig, SanityClient} from '@sanity/client'
import type {
AssetSource,
CurrentUser,
ObjectSchemaType,
SanityDocumentLike,
Schema,
SchemaType,
SchemaTypeDefinition,
} from '@sanity/types'
import type {ComponentTy... | 2,829 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/useConfigContextFromSource.ts | import {useMemo} from 'react'
import type {Source, ConfigContext} from './types'
/**
* Reduce a {@link Source} down to a {@link ConfigContext}, memoizing using `React.useMemo`
*
* @param source - Source to convert
* @returns A config context containing only the defined properties of that interface
* @internal
*/... | 2,830 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/__tests__/.eslintrc | {
"rules": {
"tsdoc/syntax": "off"
}
}
| 2,831 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/__tests__/createPlugin.test.ts | import {createPlugin} from '../definePlugin'
describe('createPlugin', () => {
it.todo('normalizes its input to a function')
it.todo('throws if a plugin contains a projectId or a dataset')
})
| 2,832 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/__tests__/resolveConfig.test.ts | import {createClient} from '@sanity/client'
import {firstValueFrom, lastValueFrom, of} from 'rxjs'
import {bufferTime} from 'rxjs/operators'
import {createMockAuthStore} from '../../store'
import {resolveConfig, createWorkspaceFromConfig, createSourceFromConfig} from '../resolveConfig'
describe('resolveConfig', () => ... | 2,833 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/__tests__/resolveConfigProperty.test.ts | import {resolveConfigProperty} from '../resolveConfigProperty'
import {definePlugin} from '../definePlugin'
describe('resolveConfigProperty', () => {
it('traverses configs and returns a resolved configuration property', () => {
const subPlugin = definePlugin({
name: 'sub-plugin',
schema: {
ty... | 2,834 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/auth/types.ts | /**
* Authentication options
*
* @public
*/
export interface AuthConfig {
/**
* Login method to use for the studio the studio. Can be one of:
* - `dual` (default) - attempt to use cookies where possible, falling back to
* storing authentication token in `localStorage` otherwise
* - `cookie` - explic... | 2,835 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/components/index.ts | export * from './useMiddlewareComponents'
| 2,836 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/components/useMiddlewareComponents.ts | /* eslint-disable @typescript-eslint/ban-types */
import {ComponentType, createElement, Fragment, useMemo} from 'react'
import {useSource} from '../../studio'
import {flattenConfig} from '../../config'
import {PluginOptions} from '../types'
const emptyRender = () => createElement(Fragment)
function _createMiddlewareC... | 2,837 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/actions.ts | import {type ButtonTone} from '@sanity/ui'
import type React from 'react'
import {type EditStateFor} from '../../store/_legacy'
/**
* @hidden
* @beta */
export interface ActionComponent<ActionProps> {
(props: ActionProps): DocumentActionDescription | null
}
/**
* @hidden
* @beta */
export interface DocumentActi... | 2,838 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/badges.ts | import {EditStateFor} from '../../store'
/**
* @hidden
* @beta */
export interface DocumentBadgeDescription {
title?: string
label?: string | undefined
color?: 'primary' | 'success' | 'warning' | 'danger'
icon?: React.ReactNode | React.ComponentType
}
/**
* @hidden
* @beta */
// eslint-disable-next-line @... | 2,839 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/index.ts | export * from './actions'
export * from './badges'
export * from './fieldActions'
export * from './inspector'
| 2,840 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/inspector.ts | import {ButtonTone} from '@sanity/ui'
import {ComponentType} from 'react'
/** @hidden @beta */
export interface DocumentInspectorProps {
documentId: string
documentType: string
onClose: () => void
}
/** @hidden @beta */
export type DocumentInspectorComponent = ComponentType<DocumentInspectorProps>
/** @hidden ... | 2,841 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/fieldActions/define.ts | import {DocumentFieldAction} from './types'
/** @internal */
export function defineDocumentFieldAction(fieldAction: DocumentFieldAction): DocumentFieldAction {
return fieldAction
}
| 2,842 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/fieldActions/index.ts | import {DocumentFieldAction} from './types'
export * from './define'
export * from './reducer'
export * from './types'
/** @internal */
export const initialDocumentFieldActions: DocumentFieldAction[] = []
| 2,843 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/fieldActions/reducer.ts | import {ConfigPropertyReducer} from '../../types'
import {DocumentFieldAction, DocumentFieldActionsResolverContext} from './types'
/** @internal */
export const documentFieldActionsReducer: ConfigPropertyReducer<
DocumentFieldAction[],
DocumentFieldActionsResolverContext
> = (prev, {document}, context) => {
cons... | 2,844 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/document/fieldActions/types.ts | import {Path, SchemaType} from '@sanity/types'
import {ComponentType, ReactNode} from 'react'
import {ComposableOption, ConfigContext} from '../../types'
/**
* @hidden
* @beta */
export interface DocumentFieldAction {
name: string
useAction: DocumentFieldActionHook
}
/**
* @hidden
* @beta */
export interface ... | 2,845 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/studio/index.ts | export * from './types'
| 2,846 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config | petrpan-code/sanity-io/sanity/packages/sanity/src/core/config/studio/types.ts | import React from 'react'
import {Tool} from '../types'
/**
* @hidden
* @beta */
// Components
export interface LayoutProps {
renderDefault: (props: LayoutProps) => React.ReactElement
}
/**
* @hidden
* @beta */
export interface LogoProps {
title: string
renderDefault: (props: LogoProps) => React.ReactElemen... | 2,847 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/environment/index.ts | /** @internal */
// eslint-disable-next-line no-process-env
export const isDev = process.env.NODE_ENV !== 'production'
/** @internal */
export const isProd = !isDev
| 2,848 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/error/ErrorLogger.tsx | import {useToast} from '@sanity/ui'
import {useEffect} from 'react'
import {ConfigResolutionError, SchemaError} from '../config'
import {CorsOriginError} from '../store'
import {globalScope} from '../util'
const errorChannel = globalScope.__sanityErrorChannel
/**
* Attaches a listener to the global error channel and... | 2,849 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/TODO.ts | import {DiffComponentResolver} from './types'
// import diffResolvers from 'all:part:@sanity/base/diff-resolver'
export const diffResolvers: DiffComponentResolver[] = []
| 2,850 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/index.ts | export * from './diff'
export * from './paths'
export * from './preview'
export * from './types'
export * from './validation'
| 2,851 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/types.ts | import {
Path,
Reference,
ArraySchemaType,
BooleanSchemaType,
NumberSchemaType,
ObjectSchemaType,
StringSchemaType,
ObjectFieldType,
ConditionalProperty,
SchemaType,
PatchOperations,
} from '@sanity/types'
import {ComponentType} from 'react'
import {
ArrayDiff as AgnosticArrayDiff,
BooleanDiff... | 2,852 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/ChangeBreadcrumbStory.tsx | import {Card, Container, Flex} from '@sanity/ui'
import React from 'react'
import {ChangeBreadcrumb} from '../diff/components/ChangeBreadcrumb'
export default function ChangeBreadCrumbStory() {
return (
<Card height="fill" padding={4} tone="transparent">
<Flex align="center" height="fill" justify="center">... | 2,853 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/ChangeListStory.tsx | import {ObjectSchemaType} from '@sanity/types'
import {Card, Container} from '@sanity/ui'
import React, {useCallback, useMemo} from 'react'
import {useSchema} from '../../hooks'
import {ChangeList, DocumentChangeContext, DocumentChangeContextInstance} from '../diff'
import {ObjectDiff, StringDiff} from '../types'
expo... | 2,854 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/ChangeResolverStory.tsx | import {ObjectSchemaType} from '@sanity/types'
import {Box, Card} from '@sanity/ui'
import React, {useCallback, useMemo} from 'react'
import {useSchema} from '../../hooks'
import {ChangeResolver, DocumentChangeContext, DocumentChangeContextInstance} from '../diff'
import {FieldChangeNode, ObjectDiff, StringDiff} from '... | 2,855 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/ChangeTitleSegmentStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {ChangeTitleSegment} from '../diff/components/ChangeTitleSegment'
export default function ChangeTitleSegmentStory() {
return (
<Box padding={4}>
<ChangeTitleSegment segment="Test" />
</Box>
)
}
| 2,856 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/DiffCardStory.tsx | import {Box, Text} from '@sanity/ui'
import React, {useMemo} from 'react'
import {DiffCard} from '../diff'
import {Diff} from '../types'
export default function DiffCardStory() {
const diff: Diff = useMemo(
() => ({
type: 'boolean',
action: 'added',
isChanged: true,
fromValue: null,
... | 2,857 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/DiffErrorBoundaryStory.tsx | import {Box, Button} from '@sanity/ui'
import React, {useCallback, useState} from 'react'
import {DiffErrorBoundary} from '../diff/components/DiffErrorBoundary'
export default function DiffErrorBoundaryStory() {
return (
<Box padding={4}>
<DiffErrorBoundary>
<Test />
</DiffErrorBoundary>
... | 2,858 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/DiffFromToStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {DiffFromTo} from '../diff'
/**
* TODO
*/
export default function DiffFromToStory() {
return (
<Box padding={4}>
<DiffFromTo {...({} as any)} />
</Box>
)
}
| 2,859 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/DiffInspectWrapperStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {DiffInspectWrapper} from '../diff/components/DiffInspectWrapper'
/**
* TODO
*/
export default function DiffInspectWrapperStory() {
return (
<Box padding={4}>
<DiffInspectWrapper {...({} as any)} />
</Box>
)
}
| 2,860 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/DiffStringStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {DiffString} from '../diff'
/**
* TODO
*/
export default function DiffStringStory() {
return (
<Box padding={4}>
<DiffString {...({} as any)} />
</Box>
)
}
| 2,861 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/DiffTooltipStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {DiffTooltip} from '../diff'
/**
* TODO
*/
export default function DiffTooltipStory() {
return (
<Box padding={4}>
<DiffTooltip {...({} as any)} />
</Box>
)
}
| 2,862 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/FallbackDiffStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {FallbackDiff} from '../diff/components/FallbackDiff'
/**
* TODO
*/
export default function FallbackDiffStory() {
return (
<Box padding={4}>
<FallbackDiff {...({} as any)} />
</Box>
)
}
| 2,863 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/FieldChangeStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {FieldChange} from '../diff/components/FieldChange'
/**
* TODO
*/
export default function FieldChangeStory() {
return (
<Box padding={4}>
<FieldChange {...({} as any)} />
</Box>
)
}
| 2,864 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/FromToArrowStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {FromToArrow} from '../diff'
export default function FromToArrowStory() {
return (
<Box padding={4}>
<FromToArrow />
</Box>
)
}
| 2,865 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/FromToStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {FromTo} from '../diff'
export default function FromToStory() {
return (
<Box padding={4}>
<FromTo />
</Box>
)
}
| 2,866 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/GroupChangeStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {GroupChange} from '../diff/components/GroupChange'
/**
* TODO
*/
export default function GroupChangeStory() {
return (
<Box padding={4}>
<GroupChange {...({} as any)} />
</Box>
)
}
| 2,867 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/MetaInfoStory.tsx | import {ImageIcon} from '@sanity/icons'
import {Box, Card} from '@sanity/ui'
import React from 'react'
import {MetaInfo} from '../diff'
export default function MetaInfoStory() {
return (
<Box padding={4}>
<MetaInfo action="Action" icon={ImageIcon} markRemoved title="Title">
<Card tone="transparent"... | 2,868 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/NoChangesStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {NoChanges} from '../diff'
export default function NoChangesStory() {
return (
<Box padding={4}>
<NoChanges />
</Box>
)
}
| 2,869 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/RevertChangesButtonStory.tsx | import {Box} from '@sanity/ui'
import React from 'react'
import {RevertChangesButton} from '../diff/components/RevertChangesButton'
export default function RevertChangesButtonStory() {
return (
<Box padding={4}>
<RevertChangesButton />
</Box>
)
}
| 2,870 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/ValueErrorStory.tsx | import {Box} from '@sanity/ui'
import {useText} from '@sanity/ui-workshop'
import React, {useMemo} from 'react'
import {ValueError} from '../diff/components/ValueError'
export default function ValueErrorStory() {
const message = useText('Message', 'Error message')!
const error = useMemo(() => ({message, value: 123... | 2,871 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/field',
title: 'field',
stories: [
{
name: 'change-breadcrumb',
title: 'Change Breadcrumb',
component: lazy(() => import('./ChangeBreadcrumbStory')),
},
{
name: ... | 2,872 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/conditional-property/index.ts | export * from './useConditionalProperty'
| 2,873 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/conditional-property/useConditionalProperty.test.tsx | import {renderHook} from '@testing-library/react'
import {createTestProvider} from '../../../../test/testUtils/TestProvider'
import {
ConditionalPropertyProps,
unstable_useConditionalProperty as useConditionalProperty,
} from './useConditionalProperty'
const dummyDocument = {
_createdAt: '2021-11-04T15:41:48Z',
... | 2,874 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/conditional-property/useConditionalProperty.tsx | import {SanityDocument, ConditionalProperty} from '@sanity/types'
import {useCurrentUser} from '../../store'
import {useUnique} from '../../util'
import {useCheckCondition} from './utils'
/**
* @internal Not yet a stable API
*/
export interface ConditionalPropertyProps {
parent?: unknown
value: unknown
documen... | 2,875 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/conditional-property/utils.tsx | import {ConditionalProperty, ConditionalPropertyCallbackContext, CurrentUser} from '@sanity/types'
import {omit} from 'lodash'
import {useMemo, useRef} from 'react'
import {isRecord} from '../../util'
export function isThenable(value: unknown): value is Promise<unknown> {
return isRecord(value) && typeof value?.then... | 2,876 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/conditional-property | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/conditional-property/__snapshots__/useConditionalProperty.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Conditional property resolver calls callback function 1`] = `
Array [
Array [
Object {
"currentUser": Object {
"email": "doug@sanity.io",
"id": "doug",
"name": "Doug",
"role": "admin",
"roles": Array [
Obj... | 2,877 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/helpers.ts | import {ChangeNode, Diff, FieldChangeNode, GroupChangeNode, ItemDiff} from '../types'
/** @internal */
export function getChangeVerb(diff: Diff): 'Added' | 'Removed' | 'Changed' {
const hadPrevValue = hasValue(diff.fromValue)
const hasNextValue = hasValue(diff.toValue)
if (!hadPrevValue && hasNextValue) {
re... | 2,878 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/index.ts | export * from './annotations'
export * from './components'
export * from './contexts/DiffContext'
export * from './contexts/DocumentChangeContext'
export * from './helpers'
export {useDocumentChange} from './hooks'
export * from './resolve'
| 2,879 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/annotations/helpers.ts | import {isIndexSegment, isKeySegment, isIndexTuple, Path, KeyedSegment} from '@sanity/types'
import {UserColorManager, UserColor} from '../../../user-color'
import {stringToPath, pathToString} from '../../paths/helpers'
import {
Annotation,
Diff,
ItemDiff,
ArrayDiff,
ObjectDiff,
StringDiff,
StringDiffSegm... | 2,880 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/annotations/hooks.ts | import {Path} from '@sanity/types'
import {useMemo} from 'react'
import {UserColor, useUserColorManager} from '../../../user-color'
import {Annotation, Diff} from '../../types'
import {getAnnotationColor, getAnnotationAtPath} from './helpers'
/** @internal */
export function useAnnotationColor(annotation?: Annotation ... | 2,881 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/annotations/index.ts | export * from './hooks'
export * from './helpers'
| 2,882 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/changes/buildChangeList.ts | import {
Path,
MultiFieldSet,
ObjectField,
ArraySchemaType,
ObjectSchemaType,
SchemaType,
} from '@sanity/types'
import {pathToString, pathsAreEqual, getItemKeySegment} from '../../paths'
import {getValueError} from '../../validation'
import {getArrayDiffItemType} from '../../schema/helpers'
import {hasPTMe... | 2,883 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/changes/helpers.ts | import {Path, PathSegment} from '@sanity/types'
import {ChangeNode, FieldChangeNode} from '../../types'
import {getItemKey} from '../../paths'
const isAddedAction = (change: ChangeNode): boolean => {
return change.type === 'field' && change.diff.action === 'added'
}
const flattenChangeNode = (changeNode: ChangeNode... | 2,884 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/changes/undoChange.ts | import {toArray} from 'rxjs/operators'
import {
isIndexSegment,
isKeyedObject,
isKeySegment,
isTypedObject,
PatchOperations,
Path,
} from '@sanity/types'
import {
diffItem,
type DiffOptions,
type InsertAfterPatch,
type SetPatch,
type UnsetPatch,
} from 'sanity-diff-patch'
import {isRecord} from '.... | 2,885 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/ChangeBreadcrumb.tsx | import React from 'react'
import {Breadcrumbs, Text} from '@sanity/ui'
import {ChevronRightIcon} from '@sanity/icons'
import {ChangeTitlePath, FieldChangeNode} from '../../types'
import {ChangeTitleSegment} from './ChangeTitleSegment'
/** @internal */
export function ChangeBreadcrumb(props: {change?: FieldChangeNode; ... | 2,886 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/ChangeList.styled.tsx | import {Popover} from '@sanity/ui'
import styled from 'styled-components'
export const ChangeListWrapper = styled.div`
display: grid;
grid-template-columns: minmax(0, 1fr);
`
export const PopoverWrapper = styled(Popover)`
/* hides the popover when the target of it has left the visible part of the window.
wit... | 2,887 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/ChangeList.tsx | import {Button, Box, Card, Grid, Stack, useClickOutside} from '@sanity/ui'
import {RevertIcon} from '@sanity/icons'
import React, {useCallback, useContext, useMemo, useState} from 'react'
import {SanityDocument} from '@sanity/client'
import {ObjectSchemaType} from '@sanity/types'
import {unstable_useConditionalProperty... | 2,888 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/ChangeResolver.tsx | import {ConditionalProperty, SanityDocument} from '@sanity/types'
import React from 'react'
import {Text} from '@sanity/ui'
import {unstable_useConditionalProperty as useConditionalProperty} from '../../conditional-property'
import {ChangeNode} from '../../types'
import {useDocumentChange} from '../hooks'
import {Field... | 2,889 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/ChangeTitleSegment.tsx | import React from 'react'
import {Box, rem, Text} from '@sanity/ui'
import styled from 'styled-components'
import {FromToIndex, Annotation, FieldChangeNode} from '../../types'
import {getAnnotationAtPath} from '../annotations'
import {DiffCard} from './DiffCard'
const RoundedCard = styled.div`
border-radius: ${({the... | 2,890 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/DiffCard.tsx | import {Path} from '@sanity/types'
import React, {forwardRef, useMemo} from 'react'
import {Card, rem} from '@sanity/ui'
import styled from 'styled-components'
import {getAnnotationAtPath, useAnnotationColor} from '../annotations'
import {Annotation, Diff} from '../../types'
import {DiffTooltip} from './DiffTooltip'
/... | 2,891 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/DiffErrorBoundary.tsx | import React from 'react'
import {ErrorOutlineIcon} from '@sanity/icons'
import {Box, Card, Flex, Text} from '@sanity/ui'
import {isDev} from '../../../environment'
/** @internal */
export interface DiffErrorBoundaryProps {
children: React.ReactNode
}
/** @internal */
export interface DiffErrorBoundaryState {
err... | 2,892 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/DiffFromTo.tsx | import {Path, SchemaType} from '@sanity/types'
import React, {createElement, CSSProperties} from 'react'
import {FieldPreviewComponent} from '../../preview'
import {Diff} from '../../types'
import {getChangeVerb} from '../helpers'
import {DiffCard} from './DiffCard'
import {DiffTooltip} from './DiffTooltip'
import {Fro... | 2,893 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/DiffInspectWrapper.tsx | import {Box, BoxProps, Card, Code, Label, Stack} from '@sanity/ui'
import React, {useCallback, useEffect, useRef, useState} from 'react'
import styled, {type ExecutionProps} from 'styled-components'
import {pathToString} from '../../paths'
import {FieldChangeNode} from '../../types'
import {FromToArrow} from './FromToA... | 2,894 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/DiffString.tsx | import {Text, Card, rem} from '@sanity/ui'
import React from 'react'
import styled from 'styled-components'
import {StringDiffSegment, StringDiff} from '../../types'
import {DiffCard} from './DiffCard'
const RoundedCard = styled.span`
border-radius: ${({theme}) => rem(theme.sanity.radius[1])};
`
const ChangeSegment... | 2,895 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/DiffTooltip.tsx | import {Path} from '@sanity/types'
import {Tooltip, TooltipProps, Text, Stack, Flex, Inline, Label} from '@sanity/ui'
import React from 'react'
import {LegacyLayerProvider, UserAvatar} from '../../../components'
import {useTimeAgo} from '../../../hooks'
import {useUser} from '../../../store'
import {AnnotationDetails, ... | 2,896 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/FallbackDiff.tsx | import React from 'react'
import {Box} from '@sanity/ui'
import {FieldPreviewComponent} from '../../preview'
import {Diff, DiffComponent} from '../../types'
import {Preview} from '../../../preview/components/Preview'
import {DiffFromTo} from './DiffFromTo'
const FallbackPreview: FieldPreviewComponent<React.ReactNode> ... | 2,897 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/FieldChange.styled.tsx | import styled from 'styled-components'
import {rem, Popover} from '@sanity/ui'
export const FieldChangeContainer = styled.div`
--field-change-error: ${({theme}) => theme.sanity.color.solid.critical.enabled.bg};
&[data-revert-all-changes-hover] [data-revert-all-hover]::before {
border-left: 2px solid var(--fiel... | 2,898 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff | petrpan-code/sanity-io/sanity/packages/sanity/src/core/field/diff/components/FieldChange.tsx | import React, {useCallback, useMemo, useState} from 'react'
import {Stack, Box, Button, Text, Grid, useClickOutside} from '@sanity/ui'
import {ObjectSchemaType} from '@sanity/types'
import {useDocumentOperation} from '../../../hooks'
import {FieldChangeNode, FieldOperationsAPI} from '../../types'
import {undoChange} fr... | 2,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.