diff --git a/packages/@sanity/import/src/importFromFolder.js b/packages/@sanity/import/src/importFromFolder.js index 5c09063cf41..220131446d6 100644 --- a/packages/@sanity/import/src/importFromFolder.js +++ b/packages/@sanity/import/src/importFromFolder.js @@ -1,8 +1,8 @@ const fs = require('fs') const path = require('path') +const debug = require('debug')('sanity:import:folder') const getFileUrl = require('file-url') const globby = require('globby') -const debug = require('debug')('sanity:import:folder') const readJson = require('./util/readJson') const rimraf = require('./util/rimraf') diff --git a/packages/@sanity/import/src/references.js b/packages/@sanity/import/src/references.js index 3cc40f4e84e..08edcb7be35 100644 --- a/packages/@sanity/import/src/references.js +++ b/packages/@sanity/import/src/references.js @@ -1,7 +1,7 @@ +const {extractWithPath} = require('@sanity/mutator') const debug = require('debug')('sanity:import') const {get} = require('lodash') const pMap = require('p-map') -const {extractWithPath} = require('@sanity/mutator') const serializePath = require('./serializePath') const progressStepper = require('./util/progressStepper') const retryOnFailure = require('./util/retryOnFailure') diff --git a/packages/@sanity/import/src/uploadAssets.js b/packages/@sanity/import/src/uploadAssets.js index 737b832e8d2..c1f62d51cda 100644 --- a/packages/@sanity/import/src/uploadAssets.js +++ b/packages/@sanity/import/src/uploadAssets.js @@ -1,8 +1,8 @@ const basename = require('path').basename const parseUrl = require('url').parse +const {isSanityImageUrl} = require('@sanity/asset-utils') const debug = require('debug')('sanity:import') const pMap = require('p-map') -const {isSanityImageUrl} = require('@sanity/asset-utils') const getHashedBufferForUri = require('./util/getHashedBufferForUri') const progressStepper = require('./util/progressStepper') const retryOnFailure = require('./util/retryOnFailure') diff --git a/packages/@sanity/import/src/validateAssetDocuments.js b/packages/@sanity/import/src/validateAssetDocuments.js index 35e6ac9f9de..97d74f26f6a 100644 --- a/packages/@sanity/import/src/validateAssetDocuments.js +++ b/packages/@sanity/import/src/validateAssetDocuments.js @@ -1,5 +1,5 @@ -const debug = require('debug')('sanity:import:asset-validation') const {generateHelpUrl} = require('@sanity/generate-help-url') +const debug = require('debug')('sanity:import:asset-validation') const pMap = require('p-map') const urlExists = require('./util/urlExists') diff --git a/packages/sanity/playwright-ct/tests/utils/testHelpers.tsx b/packages/sanity/playwright-ct/tests/utils/testHelpers.tsx index daba645b02e..b36b362feb1 100644 --- a/packages/sanity/playwright-ct/tests/utils/testHelpers.tsx +++ b/packages/sanity/playwright-ct/tests/utils/testHelpers.tsx @@ -1,16 +1,7 @@ -import {type ComponentFixtures} from '@playwright/experimental-ct-react' import {type Locator, type PlaywrightTestArgs} from '@playwright/test' export const DEFAULT_TYPE_DELAY = 20 -/** - * The delay between key presses in milliseconds for fast typing. This is usually used for typing in the PTE. - * The PTE normally need some time to process the input and sync its internal state with the document - */ -export const TYPE_DELAY_HIGH = 150 - -export type MountResult = Awaited> - export function testHelpers({page}: {page: PlaywrightTestArgs['page']}) { const activatePTInputOverlay = async ($pteField: Locator) => { const $overlay = $pteField.getByTestId('activate-overlay') diff --git a/packages/sanity/src/core/config/types.ts b/packages/sanity/src/core/config/types.ts index 84a8786e28c..388865f191f 100644 --- a/packages/sanity/src/core/config/types.ts +++ b/packages/sanity/src/core/config/types.ts @@ -10,7 +10,7 @@ import { type SchemaTypeDefinition, } from '@sanity/types' import {type i18n} from 'i18next' -import {type ComponentType, type ReactElement, type ReactNode} from 'react' +import {type ComponentType, type ReactNode} from 'react' import {type Observable} from 'rxjs' import {type Router, type RouterState} from 'sanity/router' @@ -521,7 +521,7 @@ export interface DocumentLayoutProps { * The type of the document. This is a read-only property and changing it will have no effect. */ documentType: string - renderDefault: (props: DocumentLayoutProps) => ReactElement + renderDefault: (props: DocumentLayoutProps) => React.ReactElement } interface DocumentComponents { diff --git a/packages/sanity/src/core/form/inputs/ReferenceInput/ReferenceInput.tsx b/packages/sanity/src/core/form/inputs/ReferenceInput/ReferenceInput.tsx index 87fb26f5af8..1f6b711b2e9 100644 --- a/packages/sanity/src/core/form/inputs/ReferenceInput/ReferenceInput.tsx +++ b/packages/sanity/src/core/form/inputs/ReferenceInput/ReferenceInput.tsx @@ -1,6 +1,14 @@ import {Stack, Text, useToast} from '@sanity/ui' import {uuid} from '@sanity/uuid' -import {type FocusEvent, type KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react' +import { + type FocusEvent, + forwardRef, + type KeyboardEvent, + useCallback, + useMemo, + useRef, + useState, +} from 'react' import {useObservableCallback} from 'react-rx' import {concat, type Observable, of} from 'rxjs' import {catchError, filter, map, scan, switchMap, tap} from 'rxjs/operators' @@ -28,11 +36,21 @@ import {useReferenceInfo} from './useReferenceInfo' import {useReferenceInput} from './useReferenceInput' import {useReferenceItemRef} from './useReferenceItemRef' -const StyledPreviewCard = styled(PreviewCard)` - /* this is a hack to avoid layout jumps while previews are loading - there's probably better ways of solving this */ - min-height: 36px; -` +// This is a workaround for a circular import issue. +// Calling `styled(PreviewCard)` at program load time triggered a build error with the commonjs bundle because it tried +// to access the PreviewCard variable/symbol before it was initialized. +// The workaround is to defer creating StyledPreviewCard until react render time +let StyledPreviewCardImpl: undefined | typeof PreviewCard +const StyledPreviewCard: typeof PreviewCard = forwardRef(function StyledPreviewCard(props, ref) { + if (!StyledPreviewCardImpl) { + StyledPreviewCardImpl = styled(PreviewCard)` + /* this is a hack to avoid layout jumps while previews are loading + there's probably better ways of solving this */ + min-height: 36px; + ` + } + return +}) const INITIAL_SEARCH_STATE: ReferenceSearchState = { hits: [], diff --git a/packages/sanity/src/core/form/inputs/files/FileInput/FileInput.tsx b/packages/sanity/src/core/form/inputs/files/FileInput/FileInput.tsx index 54e35d99cdd..d014f85a0aa 100644 --- a/packages/sanity/src/core/form/inputs/files/FileInput/FileInput.tsx +++ b/packages/sanity/src/core/form/inputs/files/FileInput/FileInput.tsx @@ -14,7 +14,7 @@ import { } from '@sanity/types' import {Box, Card, Menu, type ThemeColorToneKey, type ToastParams} from '@sanity/ui' import {get, startCase} from 'lodash' -import React, {type FocusEvent, PureComponent, type ReactNode} from 'react' +import {PureComponent, type ReactNode} from 'react' import {type Observable, type Subscription} from 'rxjs' import {Button, MenuButton, MenuItem} from '../../../../../ui-components' @@ -48,7 +48,7 @@ export interface BaseFileInputValue extends Partial { _upload?: UploadState } -function passThrough({children}: {children?: ReactNode}) { +function passThrough({children}: {children?: React.ReactNode}) { return children } @@ -298,7 +298,7 @@ export class BaseFileInput extends PureComponent { + handleFileTargetFocus = (event: React.FocusEvent) => { // We want to handle focus when the file target element *itself* receives // focus, not when an interactive child element receives focus. Since React has decided // to let focus bubble, so this workaround is needed