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/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/Presence.tsx
/* eslint-disable react/no-unused-prop-types */ import React, {useContext, createContext, useMemo, useRef} from 'react' import {Path} from '@sanity/types' import {startsWith, isEqual} from '@sanity/util/paths' import {FormNodePresence} from '../../../presence' import {immutableReconcile} from '../../store/utils/immutab...
3,400
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/ReferenceInputOptions.tsx
import React, {ComponentType, createContext, HTMLProps, useContext, useMemo} from 'react' import {Path} from '@sanity/types' import {TemplatePermissionsResult} from '../../../store' const Context = createContext<ReferenceInputOptions>({}) /** @internal */ export interface TemplateOption { id: string params?: Reco...
3,401
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/Validation.tsx
/* eslint-disable react/no-unused-prop-types */ import React, {createContext, useContext, useMemo} from 'react' import {FormNodeValidation, Path, ValidationMarker} from '@sanity/types' import {isEqual, startsWith} from '@sanity/util/paths' import {of} from 'rxjs' import {mergeMapTo} from 'rxjs/operators' const Validat...
3,402
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/index.ts
export * from './FormCallbacks' export * from './ReferenceInputOptions' export * from './reviewChanges'
3,403
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/reviewChanges/ReviewChangesContext.ts
import {createContext} from 'react' import {ReviewChangesContextValue} from './types' /** * @internal */ export const ReviewChangesContext = createContext<ReviewChangesContextValue | null>(null)
3,404
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/reviewChanges/ReviewChangesProvider.tsx
import React, {useMemo} from 'react' import {ReviewChangesContext} from './ReviewChangesContext' import {ReviewChangesContextValue} from './types' /** * @internal */ export function ReviewChangesContextProvider(props: { children?: React.ReactNode changesOpen: boolean }): React.ReactElement { const {children, c...
3,405
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/reviewChanges/index.ts
export * from './ReviewChangesContext' export * from './types' export * from './useReviewChanges'
3,406
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/reviewChanges/types.ts
/** * @internal */ export interface ReviewChangesContextValue { changesOpen?: boolean }
3,407
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/contexts/reviewChanges/useReviewChanges.ts
import {useContext} from 'react' import {ReviewChangesContext} from './ReviewChangesContext' import {ReviewChangesContextValue} from './types' /** * @internal */ export function useReviewChanges(): ReviewChangesContextValue { const reviewChanges = useContext(ReviewChangesContext) if (!reviewChanges) { throw...
3,408
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/focusManagers/HashFocusManager.ts
/* eslint-disable react/no-unused-prop-types */ import {Path} from '@sanity/types' import React, {useCallback, useEffect, useState} from 'react' import {decodePath, encodePath} from '../../utils/path' /** @internal */ export type HashFocusManagerChildArgs = { onFocus: (path: Path) => void onBlur: () => void foc...
3,409
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/focusManagers/SimpleFocusManager.ts
/* eslint-disable react/no-unused-prop-types */ import React from 'react' import {Path} from '@sanity/types' /** @internal */ export interface SimpleFocusManagerProps { path: any | null onFocus: () => void onBlur: () => void children: (arg: any) => any } /** @internal */ export interface SimpleFocusManagerSt...
3,410
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/focusManagers/index.ts
export * from './HashFocusManager' export * from './SimpleFocusManager'
3,411
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/blockResolver.tsx
import {SchemaType} from '@sanity/types' import React from 'react' import {BlockAnnotationProps, BlockProps} from '../../types' import {FIXME} from '../../../FIXME' import {DefaultBlockObjectComponent} from '../../inputs/PortableText/object/BlockObject' import {DefaultComponent as DefaultBlockTextComponent} from '../.....
3,412
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/defaultInputs.ts
import React from 'react' import {BooleanInput} from '../../inputs/BooleanInput' import {EmailInput} from '../../inputs/EmailInput' import {NumberInput} from '../../inputs/NumberInput' import {ObjectInput} from '../../inputs/ObjectInput' import {StringInput} from '../../inputs/StringInput' import {DateTimeInput, DateIn...
3,413
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/fieldResolver.tsx
/* eslint-disable react/jsx-handler-names */ import { isBooleanSchemaType, isCrossDatasetReferenceSchemaType, isReferenceSchemaType, SchemaType, } from '@sanity/types' import React, {useState} from 'react' import {ArrayFieldProps, FieldProps, ObjectFieldProps} from '../../types' import {ReferenceField} from '.....
3,414
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/helpers.test.ts
/* eslint max-nested-callbacks: */ import {type ObjectSchemaType, defineType, defineField} from '@sanity/types' import {validateSchema, groupProblems} from '@sanity/schema/_internal' import {createSchema} from '../../../schema' import {getFieldLevel} from './helpers' describe('inputResolver/helpers', () => { const ...
3,415
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/helpers.ts
import {isArraySchemaType, SchemaType} from '@sanity/types' import {get} from 'lodash' export function getOption(type: SchemaType, optionName: string) { return get(type.options, optionName) } const PSEUDO_OBJECTS = ['array', 'file', 'image', 'reference', 'slug'] const HIDDEN_FIELDS = ['asset', 'crop', 'hotspot', '_...
3,416
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/inputResolver.tsx
/* eslint-disable react/jsx-handler-names */ import {ArraySchemaType, NumberSchemaType, SchemaType, StringSchemaType} from '@sanity/types' import React from 'react' import {InputProps} from '../../types' import * as is from '../../utils/is' import {PreviewProps} from '../../../components' import {SanityDefaultPreview} ...
3,417
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/itemResolver.tsx
import {isReferenceSchemaType, SchemaType} from '@sanity/types' import React from 'react' import {ReferenceItem} from '../../inputs/ReferenceInput/ReferenceItem' import {PreviewItem} from '../../inputs/arrays/ArrayOfObjectsInput/List/PreviewItem' import {ItemProps} from '../../types' import {FIXME} from '../../../FIXME...
3,418
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/resolveArrayInput.ts
import {ArraySchemaType} from '@sanity/types' import {ComponentType} from 'react' import * as is from '../../utils/is' import {ArrayOfOptionsInput} from '../../inputs/arrays/ArrayOfOptionsInput' import {PortableTextInput} from '../../inputs/PortableText/PortableTextInput' import {TagsArrayInput} from '../../inputs/Tags...
3,419
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/resolveNumberInput.ts
import {NumberSchemaType} from '@sanity/types' import {SelectInput} from '../../inputs/SelectInput' import {NumberInput} from '../../inputs/NumberInput' import {getOption} from './helpers' export function resolveNumberInput(type: NumberSchemaType) { return getOption(type, 'list') ? SelectInput : NumberInput }
3,420
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/resolveReferenceInput.ts
import {ReferenceSchemaType} from '@sanity/types' import {once} from 'lodash' import {StudioReferenceInput} from '../inputs/reference/StudioReferenceInput' /* eslint-disable no-console */ const warnInputTypeNotSupported = once(() => console.warn('The option "inputType" on references is removed.'), ) const warnSearch...
3,421
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputResolver/resolveStringInput.ts
import {StringSchemaType} from '@sanity/types' import {SelectInput} from '../../inputs/SelectInput' import {StringInput} from '../../inputs/StringInput' import {getOption} from './helpers' export function resolveStringInput(type: StringSchemaType) { return getOption(type, 'list') ? SelectInput : StringInput }
3,422
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/StudioFileInput.tsx
import React, {useCallback, useMemo} from 'react' import {SchemaType} from '@sanity/types' import {BaseFileInput, BaseFileInputProps} from '../../inputs/files/FileInput' import {resolveUploader as defaultResolveUploader} from '../uploads/resolveUploader' import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../studioClien...
3,423
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/StudioImageInput.tsx
import React, {useCallback} from 'react' import imageUrlBuilder from '@sanity/image-url' import {SchemaType} from '@sanity/types' import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../studioClient' import {BaseImageInput, BaseImageInputProps} from '../../inputs/files/ImageInput' import {useFormBuilder} from '../../useF...
3,424
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/index.ts
export {type FileInputProps, StudioFileInput as FileInput} from './StudioFileInput' export {type ImageInputProps, StudioImageInput as ImageInput} from './StudioImageInput' export { type StudioReferenceInputProps as ReferenceInputProps, StudioReferenceInput as ReferenceInput, } from './reference/StudioReferenceInput...
3,425
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/client-adapters/assets.ts
import {mergeMap, map, catchError} from 'rxjs/operators' import {Observable, of as observableOf} from 'rxjs' import {FileAsset, ImageAsset} from '@sanity/types' import {SanityClient, ProgressEvent, SanityAssetDocument} from '@sanity/client' import {withMaxConcurrency} from '../../utils' import {UploadOptions} from '../...
3,426
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/client-adapters/reference.ts
import {map, mergeMap, startWith, switchMap} from 'rxjs/operators' import {ReferenceFilterSearchOptions, ReferenceSchemaType} from '@sanity/types' import {combineLatest, Observable, of} from 'rxjs' import {SanityClient} from '@sanity/client' import {ReferenceInfo, ReferenceSearchHit} from '../../../inputs/ReferenceInpu...
3,427
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/StudioCrossDatasetReferenceInput.tsx
import React, {useCallback, useMemo, useRef} from 'react' import { CrossDatasetReferenceValue, CrossDatasetReferenceSchemaType, Path, ReferenceFilterOptions, ReferenceFilterSearchOptions, SanityDocument, } from '@sanity/types' import {get} from '@sanity/util/paths' import {from, throwError} from 'rxjs' impo...
3,428
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/crossDatasetReference
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/datastores/getReferenceInfo.ts
import {map, switchMap} from 'rxjs/operators' import {CrossDatasetReferenceSchemaType} from '@sanity/types' import {combineLatest, Observable, of} from 'rxjs' import {SanityClient} from '@sanity/client' import {keyBy} from 'lodash' import {CrossDatasetReferenceInfo} from '../../../../inputs/CrossDatasetReferenceInput/t...
3,429
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/crossDatasetReference
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/crossDatasetReference/datastores/search.ts
import {SanityClient} from '@sanity/client' import {CrossDatasetReferenceSchemaType, ReferenceFilterSearchOptions} from '@sanity/types' import {Observable} from 'rxjs' import {map} from 'rxjs/operators' import {createWeightedSearch} from '../../../../../search' import {collate} from '../../../../../util' interface Sea...
3,430
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/inputs/reference/StudioReferenceInput.tsx
import { Path, Reference, ReferenceFilterSearchOptions, ReferenceOptions, ReferenceSchemaType, SanityDocument, } from '@sanity/types' import * as PathUtils from '@sanity/util/paths' import {get} from '@sanity/util/paths' import React, {ComponentProps, ForwardedRef, forwardRef, useCallback, useMemo, useRef} ...
3,431
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/locale/strings.json
{ "en-US": { "@sanity/form-builder.errors.fieldIsRequired": "This field is required" } }
3,432
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/accepts.ts
import type {FileLike} from './types' /** * Check if the provided file type should be accepted by the input with accept attribute. * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-accept * * Inspired by https://github.com/enyo/dropzone (MIT) (c) 2021 Matias Meno * Based on https://github.com...
3,433
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/constants.ts
export const UPLOAD_STATUS_KEY = '_upload'
3,434
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/index.ts
export * from './types'
3,435
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/resolveUploader.ts
import type {SchemaType} from '@sanity/types' import * as is from '../../utils/is' import {FIXME} from '../../../FIXME' import type {FileLike, Uploader} from './types' import {uploaders} from './uploaders' import {accepts} from './accepts' export function resolveUploader(type: SchemaType, file: FileLike): Uploader | n...
3,436
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/types.ts
import {SanityClient} from '@sanity/client' import {AssetSourceSpec, SchemaType, AssetMetadataType} from '@sanity/types' import {Observable} from 'rxjs' import {FormPatch} from '../../patch' /** * * @hidden * @beta */ export type UploadProgressEvent = { type: 'uploadProgress' patches: FormPatch[] | null } /** ...
3,437
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/uploadFile.ts
import {of, concat, Observable} from 'rxjs' import {map} from 'rxjs/operators' import {SanityClient} from '@sanity/client' import {set} from '../../patch' import {uploadFileAsset} from '../inputs/client-adapters/assets' import {UploadProgressEvent, UploadOptions} from './types' import {UPLOAD_STATUS_KEY} from './consta...
3,438
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/uploadImage.ts
import {concat, merge, Observable, of} from 'rxjs' import {catchError, filter, map, mergeMap} from 'rxjs/operators' import type {SanityClient} from '@sanity/client' import {set} from '../../patch' import {uploadImageAsset} from '../inputs/client-adapters/assets' import {readExif} from './image/readExif' import {rotateI...
3,439
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/uploaders.ts
import {SchemaType} from '@sanity/types' import {map} from 'rxjs/operators' import {SanityClient} from '@sanity/client' import {set} from '../../patch' import {uploadImage} from './uploadImage' import {uploadFile} from './uploadFile' import {Uploader, UploaderDef, UploadOptions} from './types' const UPLOAD_IMAGE: Uplo...
3,440
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/utils.ts
import {FormPatch, set, unset} from '../../patch' import {UploadProgressEvent} from './types' import {UPLOAD_STATUS_KEY} from './constants' const UNSET_UPLOAD_PATCH = unset([UPLOAD_STATUS_KEY]) export function createUploadEvent(patches: FormPatch[] = []): UploadProgressEvent { return { type: 'uploadProgress', ...
3,441
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/file/readAsText.ts
import {Observable} from 'rxjs' export function readAsText(file: File, encoding?: string) { return new Observable<string | null>((observer) => { const reader = new FileReader() reader.onerror = (error) => observer.error(error) reader.onload = () => { observer.next(reader.result as string | null) ...
3,442
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/image/orient.ts
import {Observable} from 'rxjs' /* eslint-disable */ /** * Check if we need to change dims. */ function rotated(n: number) { return [5, 6, 7, 8].indexOf(n) > -1 } type RotateOpts = { degrees?: number x: number y: number } // Based on github.com/component/rotate function rotate(ctx: CanvasRenderingContext2...
3,443
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/image/readExif.ts
import {Observable, of as observableOf, from as observableFrom} from 'rxjs' import {map, catchError} from 'rxjs/operators' import exif from 'exif-component' function readFileAsArrayBuffer( file: File, length: number, ): Observable<string | ArrayBuffer | null> { return new Observable((observer) => { const rea...
3,444
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/uploads/image/rotateImage.ts
import {Observable} from 'rxjs' import {mergeMap} from 'rxjs/operators' import {orient, Orientation} from './orient' function loadImage(url: string): Observable<HTMLImageElement> { return new Observable((observer) => { const image = new window.Image() //console.time("read image"); image.onerror = () => {...
3,445
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/utils/index.ts
export * from './withMaxConcurrency'
3,446
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/utils/withMaxConcurrency.ts
// Takes a observable-returning function and returns a new function that limits on the number of // concurrent observables. import {first, mergeMap} from 'rxjs/operators' import {Subject, Subscription, Observable, from as observableFrom} from 'rxjs' import {FIXME} from '../../../FIXME' const DEFAULT_CONCURRENCY = 4 f...
3,447
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/utils
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/studio/utils/tests/index.ts
export const requiredImageTypes = [ { name: 'sanity.assetSourceData', title: 'Asset Source Data', type: 'object', fields: [ { name: 'name', title: 'Source name', description: 'A canonical name for the source this asset is originating from', type: 'string', }...
3,448
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/_transitional.ts
import { ArraySchemaType, FormNodeValidation, ObjectField, ObjectSchemaType, Path, PortableTextBlock, } from '@sanity/types' import React from 'react' import {PatchEvent} from '../patch' import {PreviewProps} from '../../components' import {InputProps} from './inputProps' import {FieldProps} from './fieldPr...
3,449
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/asserters.ts
import { isArrayOfBlocksSchemaType, isArrayOfObjectsSchemaType, isArrayOfPrimitivesSchemaType, isBooleanSchemaType, isNumberSchemaType, isObjectSchemaType, isStringSchemaType, } from '@sanity/types' import { ArrayOfObjectsInputProps, ArrayOfPrimitivesInputProps, BooleanInputProps, InputProps, Nu...
3,450
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/blockProps.ts
import { ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, FormNodeValidation, ObjectSchemaType, Path, PortableTextBlock, PortableTextObject, PortableTextTextBlock, SchemaType, } from '@sanity/types' import {ReactElement, ReactNode} from 'react' import {FormNode...
3,451
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/definitionExtensions.test.ts
/* eslint-disable @typescript-eslint/no-unused-vars */ // noinspection JSUnusedLocalSymbols import { CrossDatasetReferenceValue, defineArrayMember, defineField, defineType, FileValue, GeopointValue, ImageValue, ReferenceValue, SlugValue, } from '@sanity/types' import {defineConfig} from '../../config...
3,452
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/definitionExtensions.ts
import {ComponentType} from 'react' import { CrossDatasetReferenceValue, FileValue, GeopointValue, ImageValue, ReferenceValue, SlugValue, } from '@sanity/types' import {PreviewProps} from '../../components' import {CrossDatasetReferenceInputProps, ReferenceInputProps} from '../studio' import { ArrayFieldP...
3,453
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/event.ts
import {KeyedSegment, SchemaType} from '@sanity/types' import {Uploader} from '../studio' /** * @hidden * @beta */ export interface ArrayInputInsertEvent<Item> { items: Item[] position: 'before' | 'after' referenceItem: KeyedSegment | number skipInitialValue?: boolean open?: boolean } /** * @hidden * @b...
3,454
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/fieldProps.ts
import { ArraySchemaType, BooleanSchemaType, CrossDatasetReferenceValue, FileValue, FormNodeValidation, GeopointValue, ImageValue, NumberSchemaType, ObjectSchemaType, Path, ReferenceValue, SchemaType, SlugValue, StringSchemaType, } from '@sanity/types' import {ReactElement, ReactNode} from '...
3,455
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/index.ts
export * from './_transitional' export * from './asserters' export * from './blockProps' export * from './event' export * from './fieldProps' export * from './inputProps' export * from './itemProps' export * from './renderCallback' export * from './definitionExtensions'
3,456
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/inputProps.ts
import { ArraySchemaType, BooleanSchemaType, CrossDatasetReferenceValue, FileValue, GeopointValue, ImageValue, NumberSchemaType, ObjectSchemaType, Path, PortableTextBlock, ReferenceValue, SchemaType, SlugValue, StringSchemaType, } from '@sanity/types' import React, {ComponentType, FocusEvent...
3,457
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/itemProps.ts
import { ArraySchemaType, BooleanSchemaType, CrossDatasetReferenceValue, FileValue, FormNodeValidation, GeopointValue, ImageValue, NumberSchemaType, ObjectSchemaType, Path, ReferenceValue, SchemaType, SlugValue, StringSchemaType, } from '@sanity/types' import React from 'react' import {FormN...
3,458
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/types/renderCallback.ts
import React, {ComponentType, CSSProperties, ReactNode} from 'react' import {SchemaType} from '@sanity/types' import {PreviewLayoutKey, PreviewMediaDimensions, PreviewProps} from '../../components' import {ObjectItemProps, PrimitiveItemProps} from './itemProps' import {FieldProps} from './fieldProps' import {InputProps...
3,459
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/TransformPatches.tsx
import React, {memo, useCallback, useMemo} from 'react' import {FormPatch, PatchEvent} from '../patch' import {FormCallbacksContext, useFormCallbacks} from '../studio' type PatchTransformer = (patches: FormPatch[]) => FormPatch[] /** * @hidden * @beta */ export const TransformPatches = memo(function OnChangeProvide...
3,460
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/WithReferencedAsset.tsx
import React, {ReactNode} from 'react' import {Observable} from 'rxjs' import {Reference} from '@sanity/types' import {useMemoObservable} from 'react-rx' interface Props<AssetDoc> { reference: Reference observeAsset: (assetId: string) => Observable<AssetDoc> children: (assetDocument: AssetDoc) => ReactNode wai...
3,461
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/asserters.ts
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function import {isArraySchemaType, isBooleanSchemaType, isObjectSchemaType} from '@sanity/types' import {ArrayOfObjectsInputProps, InputProps, ObjectInputProps} from '../types' import { BooleanFieldProps, FieldProps, ObjectFieldProps, P...
3,462
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/common.tsx
import {ConditionalProperty, ConditionalPropertyCallbackContext, CurrentUser} from '@sanity/types' import React, {useMemo} from 'react' export function isThenable(value: any) { return typeof value?.then === 'function' } const warningMap = new Map<string, boolean>() export function isTrueIsh( checkProperty: Condi...
3,463
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/createProtoValue.ts
import {isArraySchemaType, isObjectSchemaType, SchemaType} from '@sanity/types' export function createProtoValue(type: SchemaType): any { if (isObjectSchemaType(type)) { return type.name === 'object' ? {} : {_type: type.name} } if (isArraySchemaType(type)) { return [] } if (type.jsonType === 'string'...
3,464
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/debug.ts
import Debug from 'debug' export const debug = Debug('@sanity/form-builder')
3,465
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/ensureKey.ts
import {randomKey} from './randomKey' function hasKey<T extends {_key?: string}>(item: T): item is T & {_key: string} { return item._key !== undefined } export function ensureKey<T extends {_key?: string}>(item: T): T & {_key: string} { return hasKey(item) ? item : {...item, _key: randomKey(12)} }
3,466
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/focusUtils.ts
import {isKeyedObject, isKeySegment, Path, PathSegment} from '@sanity/types' // Tests whether a keyed value matches a given keyed pathSegment function matchesSegment(segment: PathSegment, value: unknown) { return isKeyedObject(value) && isKeySegment(segment) && value._key === segment._key } // Utility to check if t...
3,467
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/getValidationRule.ts
import type {SchemaType, RuleSpec, SchemaValidationValue, Rule} from '@sanity/types' const normalizeRules = ( validation: SchemaValidationValue | undefined, type?: SchemaType, ): Rule[] => { if (typeof validation === 'function') { throw new Error( `Schema type "${ type?.name || '<not-found>' ...
3,468
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/is.ts
import {SchemaType} from '@sanity/types' const PRIMITIVES = ['string', 'number', 'boolean'] export function is(typeName: string, type: SchemaType): boolean { return type.name === typeName || Boolean(type.type && is(typeName, type.type)) } export {is as type} export function primitive(type: SchemaType) { return ...
3,469
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/mutationPatch.ts
import {arrayToJSONMatchPath} from '@sanity/mutator' import {flatten} from 'lodash' import {SANITY_PATCH_TYPE} from '../patch' import type {FormPatchOrigin, FormPatch} from '../patch/types' import {decodePath} from './path' /** * @internal */ export type MutationPatch = Record<string, any> // @todo: complete this ty...
3,470
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/path.ts
import {arrayToJSONMatchPath} from '@sanity/mutator' import {Path, PathSegment} from '@sanity/types' const IS_NUMERIC = /^\d+$/ function unquote(str: string) { return str.replace(/^['"]/, '').replace(/['"]$/, '') } function splitAttr(segment: string) { const [attr, key] = segment.split('==') return {[attr]: un...
3,471
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/randomKey.ts
import getRandomValues from 'get-random-values-esm' // WHATWG crypto RNG - https://w3c.github.io/webcrypto/Overview.html function whatwgRNG(length = 16) { const rnds8 = new Uint8Array(length) getRandomValues(rnds8) return rnds8 } const getByteHexTable = (() => { let table: string[] return () => { if (ta...
3,472
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/subscriptionManager.ts
import {Subscription} from 'rxjs' export function createSubscriptionManager(...keys: string[]) { const registry: Record<string, Subscription> = {} function validate(key: string) { if (!keys.includes(key)) { throw new Error(`Invalid subscription key: "${key}". Must be one of: ${keys.join(', ')}`) } ...
3,473
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/fallback-preview/PreviewAny.tsx
import React from 'react' import {PreviewPrimitive} from './PreviewPrimitive' import {PreviewObject} from './PreviewObject' import {PreviewArray} from './PreviewArray' const NO_VALUE = <PreviewPrimitive value="<no value>" /> export interface PreviewAnyProps { value: Array<unknown> | Record<string, unknown> | number...
3,474
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/fallback-preview/PreviewArray.tsx
import React from 'react' import {PreviewAny} from './PreviewAny' type Props = { value: Array<any> maxDepth?: number _depth?: number } export function PreviewArray(props: Props) { const {value, maxDepth = 4, _depth = 0, ...rest} = props if (_depth >= maxDepth) { return <span>Array({value.length})</span> ...
3,475
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/fallback-preview/PreviewObject.tsx
import React from 'react' import {capitalize} from 'lodash' import {PreviewAny} from './PreviewAny' type Props = { value: Record<string, any> maxDepth?: number _depth?: number } export function PreviewObject(props: Props) { const {value, maxDepth = 4, _depth = 0, ...rest} = props const {_type, _key, ...restVa...
3,476
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils
petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/utils/fallback-preview/PreviewPrimitive.tsx
import React from 'react' type Props = { value: string | boolean | number } export function PreviewPrimitive(props: Props) { return <span>{props.value}</span> }
3,477
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/index.ts
export * from './useClient' export * from './useConnectionState' export * from './useDataset' export * from './useDocumentOperation' export * from './useDocumentOperationEvent' export * from './useEditState' export * from './useProjectId' export * from './useSchema' export * from './useSyncState' export * from './useTe...
3,478
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useClient.ts
import type {SanityClient} from '@sanity/client' import type {SourceClientOptions} from '../config' import {useSource} from '../studio' /** * React hook that returns a configured Sanity client instance based on the given configuration. * Automatically uses the correct project and dataset based on the current active ...
3,479
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useConnectionState.ts
import {distinctUntilChanged, map, mapTo, startWith, switchMap} from 'rxjs/operators' import {of, timer} from 'rxjs' import {useMemoObservable} from 'react-rx' import {useDocumentStore} from '../store' /** @internal */ export type ConnectionState = 'connecting' | 'reconnecting' | 'connected' const INITIAL: Connection...
3,480
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useDataset.ts
import {useSource} from '../studio' /** * React hook that returns the name of the current dataset * * @public * @returns The name of the current dataset * @example Using the `useDataset` hook * ```ts * function MyComponent() { * const dataset = useDataset() * // ... do something with the dataset name ... ...
3,481
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useDocumentOperation.ts
import {useMemoObservable} from 'react-rx' import {useDocumentStore, OperationsAPI} from '../store' /** @internal */ export function useDocumentOperation(publishedDocId: string, docTypeName: string): OperationsAPI { const documentStore = useDocumentStore() return useMemoObservable( () => documentStore.pair.edi...
3,482
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useDocumentOperationEvent.ts
import {useMemoObservable} from 'react-rx' import {useDocumentStore} from '../store' /** @internal */ export function useDocumentOperationEvent(publishedDocId: string, docTypeName: string) { const documentStore = useDocumentStore() return useMemoObservable( () => documentStore.pair.operationEvents(publishedDo...
3,483
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useEditState.ts
import {useMemoObservable} from 'react-rx' import {merge, timer} from 'rxjs' import {debounce, share, skip, take} from 'rxjs/operators' import {EditStateFor, useDocumentStore} from '../store' /** @internal */ export function useEditState( publishedDocId: string, docTypeName: string, priority: 'default' | 'low' =...
3,484
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useFeatureEnabled.ts
import {catchError, map, shareReplay, startWith} from 'rxjs/operators' import {Observable, of} from 'rxjs' import {SanityClient} from '@sanity/client' import {useMemoObservable} from 'react-rx' import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../studioClient' import {useClient} from './useClient' interface Features { is...
3,485
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useProjectId.ts
import {useSource} from '../studio' /** * React hook that returns the current project id * * @public * @returns The current project id * @example Using the `useProjectId` hook * ```ts * function MyComponent() { * const projectId = useProjectId() * // ... do something with the project id ... * } * ``` *...
3,486
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useReferringDocuments.ts
import {map, startWith} from 'rxjs/operators' import {useMemoObservable} from 'react-rx' import {SanityDocument} from '@sanity/types' import {useDocumentStore} from '../store' interface ReferringDocumentsState { isLoading: boolean referringDocuments: SanityDocument[] } const INITIAL_STATE: ReferringDocumentsState...
3,487
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useSchema.ts
import {Schema} from '@sanity/types' import {useSource} from '../studio' /** * React hook that returns the schema registry for the current project * * @public * @returns The schema registry for the current project * @example Using the `useSchema` hook * ```ts * function MyComponent() { * const schema = useSc...
3,488
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useSyncState.ts
import {useMemoObservable} from 'react-rx' import {map} from 'rxjs/operators' import {useDocumentStore} from '../store' /** @internal */ export interface SyncState { isSyncing: boolean } const SYNCING = {isSyncing: true} const NOT_SYNCING = {isSyncing: false} /** @internal */ export function useSyncState(published...
3,489
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useTemplates.ts
import {useSource} from '../studio' import {Template} from '../templates' /** * * @hidden * @beta */ export function useTemplates(): Template[] { return useSource().templates }
3,490
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useTimeAgo.ts
import {useEffect, useReducer} from 'react' import { differenceInDays, differenceInHours, differenceInMinutes, differenceInMonths, differenceInSeconds, differenceInWeeks, differenceInYears, format, } from 'date-fns' import pluralize from 'pluralize-esm' interface TimeSpec { timestamp: string refres...
3,491
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useTools.ts
import {Tool} from '../config' import {useSource} from '../studio' /** * * @hidden * @beta */ export function useTools(): Tool[] { return useSource().tools }
3,492
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/hooks/useValidationStatus.ts
import {useMemoObservable} from 'react-rx' import {useDocumentStore, ValidationStatus} from '../store' const INITIAL: ValidationStatus = {validation: [], isValidating: false} /** @internal */ export function useValidationStatus(publishedDocId: string, docTypeName: string): ValidationStatus { const documentStore = u...
3,493
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/presence/DocumentPreviewPresence.tsx
import {AvatarStack, Box, Card, Text, Tooltip, TooltipProps} from '@sanity/ui' import React, {useMemo} from 'react' import styled, {css, useTheme} from 'styled-components' import {usePreviewCard, UserAvatar} from '../components' import {DocumentPresence} from '../store' import {isNonNullable} from '../util' /** @inter...
3,494
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/presence/FieldPresence.styled.tsx
import styled from 'styled-components' import {Flex} from '@sanity/ui' export const FlexWrapper = styled(Flex)` & > div:first-child { flex: 1; min-width: 0; } ` export const InnerBox = styled(Flex)` height: 23px; min-width: 23px; vertical-align: top; `
3,495
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/presence/FieldPresence.tsx
import React, {memo, useContext, useId, useMemo, useRef} from 'react' import {sortBy, uniqBy} from 'lodash' import {AvatarCounter, AvatarPosition} from '@sanity/ui' import {UserAvatar} from '../components/userAvatar' import { AVATAR_DISTANCE, AVATAR_SIZE, DEFAULT_MAX_AVATARS_FIELDS, DISABLE_OVERLAY, } from './c...
3,496
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/presence/PresenceScope.tsx
import {Path} from '@sanity/types' import * as PathUtils from '@sanity/util/paths' import React, {useMemo} from 'react' import {FormFieldPresenceContext} from './context' const EMPTY_ARRAY: never[] = [] function trimChildPath(path: Path, childPath: Path) { return PathUtils.startsWith(path, childPath) ? PathUtils.tr...
3,497
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/presence/PresenceTooltip.tsx
import React, {useMemo} from 'react' import {Flex, Stack, Text, Tooltip} from '@sanity/ui' import {UserAvatar} from '../components/userAvatar' import {FormNodePresence} from './types' interface PresenceTooltipProps { children?: React.ReactElement items: FormNodePresence[] } /** * The "documentScrollElement" is b...
3,498
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/presence/constants.ts
// disable overlay rendering entirely and only display presence in fields export const DISABLE_OVERLAY = false // number of avatars to display on each fields (will be stacked and have a counter if more than 3 users in a field) export const MAX_AVATARS_DOCK = 3 export const MAX_AVATARS_GLOBAL = 3 export const DEFAULT_M...
3,499