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/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/operatorUtils.ts
export function toJSON(val: unknown): string { return JSON.stringify(val) }
3,900
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/portableTextOperators.test.ts
import {portableTextOperators} from './portableTextOperators' const fieldPath = 'body' const value = 'foo' describe('stringOperators', () => { it('should create a valid filter for portableTextEqual', () => { const filter = portableTextOperators.portableTextEqual.groqFilter({fieldPath, value}) expect(filter)...
3,901
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/portableTextOperators.ts
import {SearchButtonValueString} from '../../components/filters/common/ButtonValue' import {SearchFilterStringInput} from '../../components/filters/filter/inputs/string/String' import {defineSearchOperator, SearchOperatorButtonValue, SearchOperatorInput} from './operatorTypes' import {toJSON} from './operatorUtils' //...
3,902
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/referenceOperators.test.ts
import type {ReferenceValue} from '@sanity/types' import {referenceOperators} from './referenceOperators' const fieldPath = 'relatedArticle' const valueDocument: ReferenceValue = { _ref: 'refArticle', _type: 'article', } const valueFile: ReferenceValue = { _ref: 'refFile', _type: 'sanity.fileAsset', } const va...
3,903
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/referenceOperators.ts
import {ReferenceValue} from '@sanity/types' import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue' import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset' import {SearchFilterReferenceInput} from '../../components/filters/filter/inputs/reference/Referen...
3,904
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/slugOperators.test.ts
import {slugOperators} from './slugOperators' const fieldPath = 'slug' const value = 'foo' describe('slugOperators', () => { it('should create a valid filter for slugEqual', () => { const filter = slugOperators.slugEqual.groqFilter({fieldPath, value}) expect(filter).toEqual(`${fieldPath}.current == "${value...
3,905
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/slugOperators.ts
import {SearchButtonValueString} from '../../components/filters/common/ButtonValue' import {SearchFilterStringInput} from '../../components/filters/filter/inputs/string/String' import {defineSearchOperator, SearchOperatorButtonValue, SearchOperatorInput} from './operatorTypes' import {toJSON} from './operatorUtils' //...
3,906
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/stringOperators.test.ts
import {stringOperators} from './stringOperators' const fieldPath = 'title' const value = 'foo' describe('stringOperators', () => { it('should create a valid filter for stringEqual', () => { const filter = stringOperators.stringEqual.groqFilter({fieldPath, value}) expect(filter).toEqual(`${fieldPath} == "${...
3,907
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/definitions/operators/stringOperators.ts
import {SearchButtonValueString} from '../../components/filters/common/ButtonValue' import {SearchFilterStringInput} from '../../components/filters/filter/inputs/string/String' import {SearchFilterStringListInput} from '../../components/filters/filter/inputs/string/StringList' import {defineSearchOperator, SearchOperat...
3,908
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/hooks/useSearch.ts
import type {Schema} from '@sanity/types' import isEqual from 'lodash/isEqual' import {useCallback, useMemo, useState} from 'react' import {useObservableCallback} from 'react-rx' import {concat, EMPTY, iif, Observable, of, timer} from 'rxjs' import { catchError, debounce, distinctUntilChanged, filter, map, ...
3,909
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/hooks/useSearchHotkeys.ts
import {useGlobalKeyDown, useLayer} from '@sanity/ui' import isHotkey from 'is-hotkey' import {useCallback} from 'react' import {GLOBAL_SEARCH_KEY} from '../constants' const isSearchHotKey = isHotkey(`mod+${GLOBAL_SEARCH_KEY}`) const isEscape = isHotkey('escape') /** * This hook binds a global shortcut combination, ...
3,910
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/debug.ts
import debug from 'debug' import {DEBUG_FRAGMENT} from '../constants' const rootName = 'core:studio:navbar:search:' export default debug(rootName) export function debugWithName(name: string): debug.Debugger { const namespace = `${rootName}${name}` if (debug && debug.enabled(namespace)) { return debug(namespac...
3,911
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/documentTypesTruncated.ts
import type {SearchableType} from '../../../../../search' const DEFAULT_AVAILABLE_CHARS = 40 // excluding "+x more" suffix export function documentTypesTruncated({ availableCharacters = DEFAULT_AVAILABLE_CHARS, types, }: { availableCharacters?: number types: SearchableType[] }): string { /** * Get the to...
3,912
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/filterUtils.test.ts
import {Schema} from '@sanity/schema' import {SearchableType} from '../../../../../search' import {filterDefinitions} from '../definitions/defaultFilters' import {createFieldDefinitionDictionary, createFieldDefinitions} from '../definitions/fields' import {createFilterDefinitionDictionary} from '../definitions/filters'...
3,913
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/filterUtils.ts
import intersection from 'lodash/intersection' import isEmpty from 'lodash/isEmpty' import type {SearchableType} from '../../../../../search' import {isNonNullable} from '../../../../../util' import type {SearchFieldDefinition, SearchFieldDefinitionDictionary} from '../definitions/fields' import { getFilterDefinition...
3,914
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/getSchemaField.ts
import {isObjectSchemaType, ObjectField, SchemaType} from '@sanity/types' export function getSchemaField( schemaType: SchemaType, fieldPath: string, ): ObjectField<SchemaType> | undefined { const paths = fieldPath.split('.') const firstPath = paths[0] if (firstPath && isObjectSchemaType(schemaType)) { co...
3,915
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/hasSearchableTerms.ts
import type {SearchTerms} from '../../../../../search' /** * Check if current search terms are valid. * * By default, completely empty search terms (no search query, types or filter) are considered invalid, * unless `allowEmptyQueries` is true. */ export function hasSearchableTerms({ allowEmptyQueries, terms,...
3,916
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/isRecentSearchTerms.ts
import type {SearchTerms} from '../../../../../search' import type {RecentSearch} from '../datastores/recentSearches' export function isRecentSearchTerms(terms: SearchTerms | RecentSearch): terms is RecentSearch { return typeof (terms as RecentSearch).__recent !== 'undefined' }
3,917
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/sanitizeField.ts
import {isValidElement, ReactElement} from 'react' import {renderToString} from 'react-dom/server' /** * Convert a field value to a string (if it's a React element) and remove HTML tags. * If the field value is a string, pass through as-is. */ export function sanitizeFieldValue(name: string | ReactElement): string ...
3,918
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/search/utils/selectors.ts
import type {ObjectSchemaType, Schema, SchemaType} from '@sanity/types' import {getSearchableTypes} from '../../../../../search/common/utils' import {SearchableType} from '../../../../../search' /** * Returns a list of all available document types filtered by a search string. * Types containing the search string in ...
3,919
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/tools/StudioToolMenu.tsx
import React from 'react' import {ToolMenuProps} from '../../../../config' import {ToolCollapseMenu} from './ToolCollapseMenu' import {ToolVerticalMenu} from './ToolVerticalMenu' /** * @hidden * @beta */ export function StudioToolMenu(props: ToolMenuProps) { const {context, isSidebarOpen, ...restProps} = props ...
3,920
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/tools/ToolCollapseMenu.tsx
import {UnknownIcon} from '@sanity/icons' import React, {forwardRef, useMemo, useState} from 'react' import {startCase} from 'lodash' import {CollapseMenu, CollapseMenuButton} from '../../../../components/collapseMenu' import {useRovingFocus} from '../../../../components' import {useColorScheme} from '../../../colorSch...
3,921
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/tools/ToolLink.tsx
import React, {forwardRef, useCallback} from 'react' import {StateLink, useRouterState} from 'sanity/router' /** * @hidden * @beta */ export interface ToolLinkProps { children: React.ReactNode name: string } /** * @hidden * @beta */ export const ToolLink = forwardRef(function ToolLink( props: ToolLinkProps ...
3,922
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/tools/ToolVerticalMenu.tsx
import {PlugIcon} from '@sanity/icons' import {Button, Stack} from '@sanity/ui' import {startCase} from 'lodash' import React, {forwardRef, useMemo} from 'react' import {Tool} from '../../../../config' import {ToolLink, ToolLinkProps} from './ToolLink' interface ToolVerticalMenuProps { activeToolName?: string isVi...
3,923
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/tools/index.ts
export * from './StudioToolMenu' export * from './ToolLink'
3,924
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/userMenu/LoginProviderLogo.tsx
import React from 'react' import styled from 'styled-components' import {SanityMonogram} from '@sanity/logos' const Root = styled.div` position: absolute; width: 18px; height: 18px; background: var(--card-bg-color); bottom: -4px; right: -4px; border-radius: 50%; display: flex; justify-content: center...
3,925
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/userMenu/UserMenu.tsx
import {LeaveIcon, ChevronDownIcon, CogIcon, CheckmarkIcon, UsersIcon} from '@sanity/icons' import { Box, Button, Card, Flex, Label, Menu, MenuButton, MenuButtonProps, MenuDivider, MenuItem, Stack, Text, Tooltip, } from '@sanity/ui' import React, {useMemo} from 'react' import styled from 'styl...
3,926
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/userMenu/index.ts
export * from './UserMenu'
3,927
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/WorkspaceMenuButton.tsx
import {SelectIcon} from '@sanity/icons' import { Button, MenuButton, MenuItem, Menu, MenuButtonProps, Box, Label, Tooltip, Text, Stack, } from '@sanity/ui' import React, {useCallback, useMemo, useState} from 'react' import styled from 'styled-components' import {useActiveWorkspace} from '../../../a...
3,928
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/WorkspacePreview.tsx
import {CheckmarkIcon} from '@sanity/icons' import {Flex, Stack, Box, Text, Card} from '@sanity/ui' import React, {createElement, isValidElement, useMemo} from 'react' import {isValidElementType} from 'react-is' import styled from 'styled-components' const STATE_TITLES = { 'logged-in': '', 'logged-out': 'Signed ou...
3,929
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/constants.ts
export const WORKSPACES_DOCS_URL = 'https://beta.sanity.io/docs/platform/studio/config/workspaces'
3,930
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/index.ts
export * from './WorkspaceAuth' export * from './WorkspaceMenuButton' export * from './WorkspacePreview'
3,931
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/WorkspaceAuth/Layout.tsx
import {SanityLogo} from '@sanity/logos' import {Box, Card, Flex, Heading, Stack, Text} from '@sanity/ui' import React from 'react' import styled from 'styled-components' const LINKS = [ { url: 'https://slack.sanity.io/', title: 'Community', }, { url: 'https://www.sanity.io/docs', title: 'Docs', ...
3,932
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/WorkspaceAuth/WorkspaceAuth.tsx
import {Box, Button, Card, Flex, Stack} from '@sanity/ui' import React, {useCallback, useState} from 'react' import {omit} from 'lodash' import {AddIcon, ArrowLeftIcon, ChevronRightIcon} from '@sanity/icons' import {useActiveWorkspace} from '../../../../activeWorkspaceMatcher' import {useWorkspaces} from '../../../../w...
3,933
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/WorkspaceAuth/index.ts
export * from './WorkspaceAuth'
3,934
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/hooks/index.ts
export * from './useWorkspaceAuthStates'
3,935
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/components/navbar/workspace/hooks/useWorkspaceAuthStates.ts
import {map} from 'rxjs/operators' import {combineLatest} from 'rxjs' import {WorkspaceSummary} from '../../../../../config' import {createHookFromObservableFactory} from '../../../../../util' export const useWorkspaceAuthStates = createHookFromObservableFactory( (workspaces: WorkspaceSummary[]) => combineLatest...
3,936
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router/RouterHistoryContext.tsx
import React, {createContext, useContext} from 'react' import type {RouterHistory} from './types' /** * Internal use only. Userland should leverage the public `useRouter` APIs. * @internal */ const RouterHistoryContext = createContext<RouterHistory | null>(null) /** @internal */ export function RouterHistoryProvid...
3,937
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router/helpers.ts
import {isRecord} from '../../util/isRecord' import type {Tool} from '../../config' import type {RouterEvent, RouterStateEvent} from './types' import {getOrderedTools} from './util/getOrderedTools' import type {RouterState, Router} from 'sanity/router' const WEIGHTED_CREATE_INTENT_PARAMS = ['template'] const WEIGHTED_...
3,938
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router/index.ts
export * from './router' export * from './types'
3,939
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router/router.ts
import type {Tool} from '../../config' import {route, type Router} from 'sanity/router' export function createRouter(opts: {basePath?: string; tools: Tool[]}): Router { const {basePath = '/', tools} = opts const toolRoute = route.create('/:tool', (toolParams) => { let tool = tools.find((current) => current.na...
3,940
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router/types.ts
import type {History, BrowserHistory, MemoryHistory, HashHistory} from 'history' export interface RouterStateEvent { type: 'state' state: Record<string, unknown> // | null isNotFound: boolean } export interface RouterIntentEvent { type: 'intent' intent: {name: string; params: Record<string, unknown>} isNo...
3,941
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/router/util/getOrderedTools.ts
import {Tool} from '../../../config' export function getOrderedTools(tools: Tool[]): Tool[] { const pluginConfig: {toolSwitcher?: {order?: string[]; hidden?: string[]}} = {} const config = pluginConfig.toolSwitcher || {} const order = config.order || [] const hidden = config.hidden || [] if (!order.length &...
3,942
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/AuthenticateScreen.tsx
import {Flex, Card, Container} from '@sanity/ui' import React from 'react' import {WorkspaceAuth} from '../components/navbar/workspace' export function AuthenticateScreen() { return ( <Card height="fill" overflow="auto"> <Flex height="fill" direction="column" align="center" justify="center" paddingTop={4}>...
3,943
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/ConfigErrorsScreen.tsx
import React from 'react' // const Root = styled(Card).attrs({height: 'fill', overflow: 'auto'})`` // const Content = styled(Box).attrs({padding: 4})` // margin: auto; // width: 640px; // max-width: 100%; // ` export function ConfigErrorsScreen() { /* This screen is not currently being used anywhere. We're ke...
3,944
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/CorsOriginErrorScreen.tsx
import {Card, Dialog, Stack, Button, Text, TextInput, Flex} from '@sanity/ui' import React, {useEffect, useMemo} from 'react' import {LaunchIcon} from '@sanity/icons' import styled from 'styled-components' interface CorsOriginErrorScreenProps { projectId?: string } export const ScreenReaderLabel = styled.label` c...
3,945
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/LoadingScreen.tsx
import React from 'react' import {Flex, Spinner, Card, Text} from '@sanity/ui' export function LoadingScreen() { return ( // TODO: improve the design of this // think about having it load in the `_document` too <Flex // TODO: currently this card is here to accommodate dark mode vs light // mo...
3,946
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/NoSourcesScreen.tsx
import {WarningOutlineIcon} from '@sanity/icons' import {Box, Card, Container, Flex, Stack, Text} from '@sanity/ui' import React from 'react' export function NoSourcesScreen() { return ( <Card height="fill"> <Flex align="center" height="fill" justify="center" padding={4} sizing="border"> <Container...
3,947
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/NoToolsScreen.tsx
import {WarningOutlineIcon} from '@sanity/icons' import {Box, Card, Container, Flex, Stack, Text} from '@sanity/ui' import React from 'react' export function NoToolsScreen() { return ( <Card height="fill"> <Flex align="center" height="fill" justify="center" padding={4} sizing="border"> <Container w...
3,948
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/NotAuthenticatedScreen.tsx
import {CurrentUser} from '@sanity/types' import {Button, Card, Dialog, Stack, Text} from '@sanity/ui' import React, {useCallback, useEffect, useState} from 'react' import {getProviderTitle} from '../../store' import {useActiveWorkspace} from '../activeWorkspaceMatcher' export function NotAuthenticatedScreen() { con...
3,949
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/NotFoundScreen.tsx
import {Button, Card, Flex, Heading, Inline, Stack} from '@sanity/ui' import React from 'react' export function NotFoundScreen(props: {onNavigateToDefaultWorkspace: () => void}) { return ( <Card height="fill" sizing="border" tone="caution" display="flex"> <Flex direction="row" justify="center" flex={1} ali...
3,950
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/RedirectingScreen.tsx
import React from 'react' import {DoubleChevronRightIcon} from '@sanity/icons' import {Box, Card, Container, Flex, Stack, Text} from '@sanity/ui' export function RedirectingScreen(props: {reason?: string}) { const {reason = 'Redirecting…'} = props return ( <Card height="fill"> <Flex align="center" heigh...
3,951
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/ToolNotFoundScreen.tsx
import {WarningOutlineIcon} from '@sanity/icons' import {Box, Card, Container, Flex, Stack, Text} from '@sanity/ui' import React from 'react' export function ToolNotFoundScreen(props: {toolName: string}) { const {toolName} = props return ( <Card height="fill"> <Flex align="center" height="fill" justify=...
3,952
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/index.ts
export * from './LoadingScreen' export * from './schemaErrors' export * from './NotFoundScreen' export * from './AuthenticateScreen' export * from './ConfigErrorsScreen' export * from './NotAuthenticatedScreen' export * from './CorsOriginErrorScreen'
3,953
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/schemaErrors/InitialValueTemplateError.tsx
import {Box, Dialog, Stack, Text} from '@sanity/ui' import React from 'react' export function InitialValueTemplateError({errors}: {errors: Error[]}) { return ( <Dialog header="Initial value template error" id="initial-value-error-dialog" width={1}> <Box padding={4}> <Stack space={4}> <Tex...
3,954
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/schemaErrors/SchemaErrorsScreen.tsx
import {Schema} from '@sanity/types' import {Card, Container, Heading, Stack} from '@sanity/ui' import React, {useEffect} from 'react' import {SchemaProblemGroups} from './SchemaProblemGroups' import {reportWarnings} from './reportWarnings' interface SchemaErrorsScreenProps { schema: Schema } export function Schema...
3,955
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/schemaErrors/SchemaProblemGroups.tsx
import {ErrorOutlineIcon, WarningOutlineIcon} from '@sanity/icons' import {Box, Breadcrumbs, Card, Flex, Stack, Text, ThemeColorToneKey} from '@sanity/ui' import {generateHelpUrl} from '@sanity/generate-help-url' import {SchemaValidationProblemGroup} from '@sanity/types' import React, {useMemo} from 'react' import styl...
3,956
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/schemaErrors/index.ts
export * from './SchemaErrorsScreen'
3,957
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/schemaErrors/reportWarnings.ts
import {Schema} from '@sanity/types' import {renderPath} from './utils' export function reportWarnings(schema: Schema) { /* eslint-disable no-console */ const problemGroups = schema._validation const groupsWithWarnings = problemGroups?.filter((group) => group.problems.some((problem) => problem.severity === ...
3,958
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/screens/schemaErrors/utils.ts
import {SchemaValidationProblemPath} from '@sanity/types' export function renderPath(path: SchemaValidationProblemPath) { return path .map((segment) => { if (segment.kind === 'type') { return `${segment.name || '<unnamed>'}(${segment.type})` } if (segment.kind === 'property') { ...
3,959
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/studio-components-hooks/componentHooks.ts
import {ComponentType} from 'react' import {LayoutProps, LogoProps, NavbarProps, ToolMenuProps} from '../../config/studio' import {useMiddlewareComponents} from '../../config' import {StudioLogo, StudioNavbar, StudioToolMenu} from '../components' import {StudioLayout} from '../StudioLayout' import { pickToolMenuCompo...
3,960
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/studio-components-hooks/index.ts
export * from './componentHooks'
3,961
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/studio-components-hooks/picks.ts
import {ComponentType} from 'react' import {LayoutProps, LogoProps, NavbarProps, PluginOptions, ToolMenuProps} from '../../config' export function pickToolMenuComponent( plugin: PluginOptions, ): ComponentType<Omit<ToolMenuProps, 'renderDefault'>> { return plugin.studio?.components?.toolMenu as ComponentType<Omit<...
3,962
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaceLoader/ErrorMessage.tsx
import React, {useEffect} from 'react' import {Flex, Box, Card, Code, Text} from '@sanity/ui' import {startCase} from 'lodash' import styled from 'styled-components' const ListItem = styled(Flex)`` const ErrorMessageRoot = styled(Box).attrs({padding: 4})`` export interface ErrorMessageProps { message: string sta...
3,963
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaceLoader/WorkspaceLoader.tsx
import React, {useEffect, useState} from 'react' import {map, catchError} from 'rxjs/operators' import {combineLatest, of} from 'rxjs' import {ErrorBoundary} from '@sanity/ui' import {ConfigResolutionError, Source, Workspace} from '../../config' import {useActiveWorkspace} from '../activeWorkspaceMatcher' import {Works...
3,964
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaceLoader/WorkspaceRouterProvider.tsx
import {escapeRegExp, isEqual} from 'lodash' import React, {useEffect, useMemo, useRef} from 'react' import {useSyncExternalStoreWithSelector} from 'use-sync-external-store/with-selector' import type {Tool, Workspace} from '../../config' import {createRouter, type RouterStateEvent, type RouterHistory} from '../router' ...
3,965
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaceLoader/flattenErrors.ts
import {ConfigResolutionError, ConfigPropertyError} from '../../config' import {isRecord} from '../../util' import {ErrorMessageProps} from './ErrorMessage' export function flattenErrors( error: unknown, path: Array<{name: string; type: string}>, ): ErrorMessageProps[] { if (error instanceof ConfigResolutionErro...
3,966
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaceLoader/index.ts
export * from './ErrorMessage' export * from './WorkspaceLoader'
3,967
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/WorkspaceValidationError.ts
import {getWorkspaceIdentifier} from './helpers' import type {WorkspaceLike} from './types' export interface WorkspaceValidationErrorOptions { workspace: WorkspaceLike index: number } /** * Thrown on workspace validation errors. Includes an identifier that is either the name of * the workspace, or in the case o...
3,968
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/WorkspacesContext.ts
import {createContext} from 'react' import {WorkspaceSummary} from '../../config' /** @internal */ export type WorkspacesContextValue = WorkspaceSummary[] /** @internal */ export const WorkspacesContext = createContext<WorkspacesContextValue | null>(null)
3,969
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/WorkspacesProvider.tsx
import React, {useMemo} from 'react' import {Config, prepareConfig} from '../../config' import {WorkspacesContext} from './WorkspacesContext' /** @internal */ export interface WorkspacesProviderProps { config: Config children: React.ReactNode basePath?: string } /** @internal */ export function WorkspacesProvid...
3,970
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/helpers.ts
import {WorkspaceLike} from './types' /** * Gets a printable identifer for the workspace - either the name, or the index * and any potential title set for it * * @param workspace - The workspace to get the indentifier for * @param index - The index at which the workspace appeared in the source array * @returns P...
3,971
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/index.ts
export * from './WorkspacesContext' export * from './WorkspacesProvider' export * from './helpers' export * from './types' export * from './useWorkspaces' export * from './validateWorkspaces'
3,972
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/types.ts
/** @internal */ export interface WorkspaceLike { name?: string title?: string basePath?: string }
3,973
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/useWorkspaces.ts
import {useContext} from 'react' import {WorkspaceSummary} from '../../config' import {WorkspacesContext} from './WorkspacesContext' /** @internal */ export function useWorkspaces(): WorkspaceSummary[] { const workspaces = useContext(WorkspacesContext) if (!workspaces) throw new Error('Could not find `workspaces` ...
3,974
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/validateWorkspaces.ts
import {getWorkspaceIdentifier, getNamelessWorkspaceIdentifier} from './helpers' import type {WorkspaceLike} from './types' import {WorkspaceValidationError} from './WorkspaceValidationError' /** @internal */ export interface ValidateWorkspaceOptions { workspaces: WorkspaceLike[] } /** * Validates workspace config...
3,975
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces
petrpan-code/sanity-io/sanity/packages/sanity/src/core/studio/workspaces/__tests__/validateWorkspaces.test.ts
import {validateBasePaths, validateNames} from '../validateWorkspaces' describe('validateBasePaths', () => { it('allows empty basePaths', () => { validateBasePaths([{name: 'foo', basePath: '/'}]) validateBasePaths([{name: 'foo', basePath: ''}]) validateBasePaths([{name: 'foo', basePath: undefined}]) })...
3,976
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/index.ts
export {prepareTemplates, defaultTemplateForType, defaultTemplatesForSchema} from './prepare' export type {Serializeable} from './resolve' export { DEFAULT_MAX_RECURSION_DEPTH, isBuilder, resolveInitialValue, resolveInitialValueForType, resolveInitialObjectValue, } from './resolve' export * from './types'
3,977
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/prepare.ts
import {Schema, SchemaType} from '@sanity/types' import {isBuilder} from './resolve' import {Template} from './types' import {validateTemplates} from './validate' function maybeSerialize(template: Template) { return isBuilder(template) ? template.serialize() : template } function isNonNullable<T>(t: T): t is NonNul...
3,978
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/resolve.ts
import { ArraySchemaType, InitialValueProperty, InitialValueResolver, InitialValueResolverContext, isArraySchemaType, isObjectSchemaType, ObjectSchemaType, Schema, SchemaType, } from '@sanity/types' import {isDeepEmpty, randomKey, resolveTypeName} from '@sanity/util/content' import {isRecord} from './...
3,979
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/types.ts
import type {InitialValueProperty, SchemaType} from '@sanity/types' import type {ElementType, ReactElement} from 'react' /** * An initial value template is a template that can be used to create a new documents. * * This allows a document type to have multiple different starting values while having the same * share...
3,980
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/validate.ts
import {toString as pathToString} from '@sanity/util/paths' import {randomKey} from '@sanity/util/content' import {Schema} from '@sanity/types' import {TemplateParameter, Template} from './types' import {isRecord} from './util/isRecord' const ALLOWED_REF_PROPS = ['_key', '_ref', '_weak', '_type'] const REQUIRED_TEMPLA...
3,981
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__/.eslintrc
{ "env": { "browser": true, "node": true }, "rules": { "no-sync": 0 } }
3,982
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__/prepare.test.ts
import {prepareTemplates, defaultTemplatesForSchema} from '../' import {schema} from './schema' describe('getTemplates', () => { test('returns defaults if part is not implemented', () => { const templates = defaultTemplatesForSchema(schema) expect(templates).toMatchSnapshot() }) test('returns defined te...
3,983
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__/resolve.test.ts
import {omit} from 'lodash' import {InitialValueResolverContext} from '@sanity/types' import {Schema as SchemaBuilder} from '@sanity/schema' import {resolveInitialValue, Template} from '../' import {schema} from './schema' beforeEach(() => { jest.resetModules() }) const example: Template = { id: 'author', title...
3,984
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__/resolveDeep.test.ts
import {InitialValueResolverContext} from '@sanity/types' import {resolveInitialValue} from '../' import {resolveValue} from '../resolve' import {defaultTemplatesForSchema} from '../prepare' import {schema} from './schema' function generateNestedObjectTest( obj: Record<string, any>, maxDepth: number, depth?: num...
3,985
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__/schema.ts
import {Schema as SchemaBuilder} from '@sanity/schema' import {Schema} from '@sanity/types' const Icon = () => null export const schema = SchemaBuilder.compile({ name: 'default', types: [ { name: 'author', title: 'Author', type: 'document', icon: Icon, fields: [ { ...
3,986
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/__tests__/__snapshots__/prepare.test.ts.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`getTemplates returns defaults if part is not implemented 1`] = ` Array [ Object { "icon": [Function], "id": "author", "schemaType": "author", "title": "Author", "value": [Function], }, Object { "icon": [Function], "id": "person", ...
3,987
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/util/deepAssign.test.ts
import deepAssign from './deepAssign' it('ignores undefined values', () => { expect(deepAssign({foo: undefined}, {bar: undefined})).toStrictEqual({ foo: undefined, bar: undefined, }) }) it('assigns undefined values from source', () => { expect(deepAssign({foo: 'bar', bar: 'hello'}, {foo: undefined})).to...
3,988
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/util/deepAssign.ts
import {isRecord} from './isRecord' // deep object assign for objects // note: doesn't mutate target export default function deepAssign( target: Record<string, unknown>, source: Record<string, unknown>, ): Record<string, unknown> { const result = {...target, ...source} Object.keys(result).forEach((key) => { ...
3,989
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates
petrpan-code/sanity-io/sanity/packages/sanity/src/core/templates/util/isRecord.ts
import {isPlainObject} from 'lodash' export function isRecord(value: unknown): value is Record<string, unknown> { return isPlainObject(value) }
3,990
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/index.ts
import {studioTheme} from '@sanity/ui' import {StudioTheme} from './types' export * from './_legacy' export * from './types' /** @internal */ export const defaultTheme: StudioTheme = { ...studioTheme, focusRing: {offset: -1, width: 2}, }
3,991
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/types.ts
import type {RootTheme, ThemeColorSchemeKey} from '@sanity/ui' /** @public */ export interface StudioTheme extends RootTheme { /** @internal */ __dark?: boolean /** @internal */ __legacy?: boolean } /** * Used to specify light or dark mode, or to respect system settings (prefers-color-scheme media query) use...
3,992
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/color.ts
import {hues} from '@sanity/color' import {createColorTheme, rgba, ThemeColorSchemes} from '@sanity/ui' import {_multiply, _screen, _isDark} from './helpers' import {LegacyPalette} from './palette' import {LegacyTones} from './tones' import {LegacyThemeTints} from './types' const NEUTRAL_TONES = ['default', 'transpare...
3,993
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/fonts.ts
import {studioTheme as defaults, ThemeFonts} from '@sanity/ui' import {LegacyThemeProps} from './types' export function buildFonts(cssCustomProperties: LegacyThemeProps): ThemeFonts { return { ...defaults.fonts, code: { ...defaults.fonts.code, family: cssCustomProperties['--font-family-monospace'...
3,994
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/helpers.ts
import {parseColor, rgbToHex, screen, multiply} from '@sanity/ui' import {getLuminance, mix, parseToRgb, rgb} from 'polished' import {LegacyThemeTints} from './types' /** * @internal */ export function _buildTints(bg: string, mid: string, fg: string): LegacyThemeTints { return { 50: mix(0.1, mid, bg), 100:...
3,995
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/index.ts
export * from './theme' export * from './types'
3,996
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/palette.ts
import {_toHex} from './helpers' import {LegacyThemeProps} from './types' export interface LegacyPalette { black: string component: { bg: string fg: string } defaultButton: { default: { base: string } primary: { base: string } success: { base: string } warn...
3,997
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/theme.ts
import {black, blue, gray, green, red, white, yellow} from '@sanity/color' import {studioTheme as defaults} from '@sanity/ui' import {StudioTheme} from '../types' import {buildColor} from './color' import {buildFonts} from './fonts' import {_isDark} from './helpers' import {buildLegacyPalette} from './palette' import {...
3,998
0
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme
petrpan-code/sanity-io/sanity/packages/sanity/src/core/theme/_legacy/tones.ts
import {_buildTints, _isDark} from './helpers' import {LegacyThemeTints} from './types' import {LegacyPalette} from './palette' export interface LegacyTones { button: { default: { bg: string fg: string dark: boolean default: LegacyThemeTints transparent: LegacyThemeTints prim...
3,999