{
- if (collapse) {
- return (
-
- )
- }
+ const handleClose = useCallback(() => {
+ setFocusedId('')
+ }, [])
+ const button = useMemo(() => {
return (
-
+
)
- }, [collapse, hasPresence, presence, t])
+ }, [hasPresence, t])
const popoverProps = useMemo(
(): MenuButtonProps['popover'] => ({
@@ -99,26 +74,22 @@ export function PresenceMenu(props: PresenceMenuProps) {
-
+
Value:
diff --git a/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateEqualStory.tsx b/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateEqualStory.tsx
index 1704a2efe47..eb5685fd73f 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateEqualStory.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateEqualStory.tsx
@@ -21,7 +21,7 @@ export default function CommonDateEqualStory() {
-
+
Value:
diff --git a/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateRangeStory.tsx b/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateRangeStory.tsx
index f6a6c7ff13e..c5ca3f39a51 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateRangeStory.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/__workshop__/CommonDateRangeStory.tsx
@@ -22,7 +22,7 @@ export default function CommonDateRangeStory() {
-
+
Start:
@@ -30,7 +30,7 @@ export default function CommonDateRangeStory() {
-
+
End:
diff --git a/packages/sanity/src/core/studio/components/navbar/search/__workshop__/SearchPopoverStory.tsx b/packages/sanity/src/core/studio/components/navbar/search/__workshop__/SearchPopoverStory.tsx
index 086f14a1a46..93ff5434de8 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/__workshop__/SearchPopoverStory.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/__workshop__/SearchPopoverStory.tsx
@@ -14,7 +14,6 @@ export default function SearchFieldStory() {
onClose={noop}
onOpen={noop}
open
- position={{x: 0, y: 0}}
/>
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/NoResults.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/NoResults.tsx
index 1edd708f1a6..bf1baa9f39e 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/NoResults.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/NoResults.tsx
@@ -8,7 +8,7 @@ export function NoResults() {
return (
-
+
{t('search.no-results-title')}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/SearchError.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/SearchError.tsx
index 1dc8b8784c1..8914145924c 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/SearchError.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/SearchError.tsx
@@ -22,7 +22,7 @@ export function SearchError() {
-
+
{t('search.error.unspecified-error-title')}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/SearchHeader.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/SearchHeader.tsx
index 150b33ae9c9..f5c9bc80a7a 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/SearchHeader.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/SearchHeader.tsx
@@ -1,10 +1,12 @@
import {ArrowLeftIcon, ControlsIcon, SearchIcon, SpinnerIcon} from '@sanity/icons'
-import {Box, Button, Card, Flex, Theme} from '@sanity/ui'
+import {Box, Card, Flex} from '@sanity/ui'
import React, {forwardRef, useCallback, useEffect, useRef} from 'react'
import styled, {keyframes} from 'styled-components'
+import {Button} from '../../../../../../ui-components'
+import {StatusButton} from '../../../../../components'
+import {useTranslation} from '../../../../../i18n'
import {useSearchState} from '../contexts/search/useSearchState'
import {CustomTextInput} from './common/CustomTextInput'
-import {useTranslation} from '../../../../../i18n'
const rotate = keyframes`
from {
@@ -19,20 +21,11 @@ const AnimatedSpinnerIcon = styled(SpinnerIcon)`
animation: ${rotate} 500ms linear infinite;
`
-const FilterBox = styled(Box)`
+const FilterDiv = styled.div`
+ line-height: 0;
position: relative;
`
-const NotificationBadge = styled.div`
- background: ${({theme}: {theme: Theme}) => theme.sanity.color.selectable?.primary.enabled.fg};
- border-radius: 100%;
- height: 6px;
- position: absolute;
- right: 2px;
- top: 2px;
- width: 6px;
-`
-
interface SearchHeaderProps {
ariaInputLabel: string
onClose?: () => void
@@ -89,32 +82,33 @@ export const SearchHeader = forwardRef(func
{/* (Fullscreen) Close button */}
{fullscreen && (
-
-
-
+
)}
{/* Search field */}
@@ -122,22 +116,25 @@ export const SearchHeader = forwardRef(func
{/* Filter toggle */}
{fullscreen && (
-
-
+
)}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/SearchPopover.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/SearchPopover.tsx
index b296bdfa565..861bd141e38 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/SearchPopover.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/SearchPopover.tsx
@@ -1,9 +1,9 @@
-import {Card, Portal, Theme, useClickOutside, useLayer} from '@sanity/ui'
-import React, {useCallback, useState} from 'react'
+import {Card, Portal, useClickOutside, useLayer} from '@sanity/ui'
+import {AnimatePresence, motion, Transition, Variants} from 'framer-motion'
+import React, {useCallback, useRef, useState} from 'react'
import FocusLock from 'react-focus-lock'
-import styled, {css} from 'styled-components'
+import styled from 'styled-components'
import {supportsTouch} from '../../../../../util'
-import {useColorScheme} from '../../../../colorScheme'
import {
POPOVER_INPUT_PADDING,
POPOVER_MAX_HEIGHT,
@@ -19,20 +19,32 @@ import {RecentSearches} from './recentSearches/RecentSearches'
import {SearchHeader} from './SearchHeader'
import {SearchResults} from './searchResults/SearchResults'
-export type PopoverPosition = {
- x: number | null
- y: number
-}
export interface SearchPopoverProps {
disableFocusLock?: boolean
onClose: () => void
onOpen: () => void
open: boolean
- position: PopoverPosition
}
-const Overlay = styled.div`
- background-color: ${({theme}: {theme: Theme}) => theme.sanity.color.base.shadow.ambient};
+const ANIMATION_TRANSITION: Transition = {
+ duration: 0.4,
+ type: 'spring',
+}
+
+const CARD_VARIANTS: Variants = {
+ open: {opacity: 1, scale: 1, x: '-50%'},
+ closed: {opacity: 0, scale: 0.99, x: '-50%'},
+}
+
+const OVERLAY_VARIANTS: Variants = {
+ open: {opacity: 1},
+ closed: {opacity: 0},
+}
+
+const Y_POSITION = 12 // vh
+
+const MotionOverlay = styled(motion(Card))`
+ background-color: var(--card-backdrop-color);
bottom: 0;
left: 0;
position: absolute;
@@ -40,37 +52,25 @@ const Overlay = styled.div`
top: 0;
`
-const SearchPopoverCard = styled(Card)<{$position: PopoverPosition}>`
- ${({$position}) =>
- $position.x
- ? css`
- left: ${$position.x}px;
- `
- : css`
- left: 50%;
- transform: translateX(-50%);
- `}
+const SearchMotionCard = styled(motion(Card))`
display: flex !important;
flex-direction: column;
- max-height: ${({$position}) =>
- `min(calc(100vh - ${$position.y}px - ${POPOVER_INPUT_PADDING}px), ${POPOVER_MAX_HEIGHT}px)`};
+ left: 50%;
+ max-height: min(
+ calc(100vh - ${Y_POSITION}vh - ${POPOVER_INPUT_PADDING}px),
+ ${POPOVER_MAX_HEIGHT}px
+ );
position: absolute;
- top: ${({$position}) => $position.y}px;
+ top: ${Y_POSITION}vh;
width: min(calc(100vw - ${POPOVER_INPUT_PADDING * 2}px), ${POPOVER_MAX_WIDTH}px);
`
-export function SearchPopover({
- disableFocusLock,
- onClose,
- onOpen,
- open,
- position,
-}: SearchPopoverProps) {
- const [popoverElement, setPopoverElement] = useState(null)
+export function SearchPopover({disableFocusLock, onClose, onOpen, open}: SearchPopoverProps) {
const [inputElement, setInputElement] = useState(null)
+ const popoverElement = useRef(null)
+
const {isTopLayer, zIndex} = useLayer()
- const {scheme} = useColorScheme()
const {t} = useTranslation()
const {
@@ -89,45 +89,59 @@ export function SearchPopover({
}
}, [isTopLayer, onSearchClose, open])
- useClickOutside(handleClickOutside, [popoverElement])
+ useClickOutside(handleClickOutside, [popoverElement.current])
return (
-
-
-
-
-
-
- {filtersVisible && (
-
-
-
- )}
- {hasValidTerms ? (
-
- ) : (
-
- )}
-
-
-
+
+ {open && (
+
+
+
+
+
+
+ {filtersVisible && (
+
+
+
+ )}
+ {hasValidTerms ? (
+
+ ) : (
+
+ )}
+
+
+
+ )}
+
)
}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/SortMenu.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/SortMenu.tsx
index eb4f431d3cd..482655b5ba4 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/SortMenu.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/SortMenu.tsx
@@ -1,21 +1,11 @@
import {SortIcon} from '@sanity/icons'
-import {
- Box,
- Button,
- Card,
- Flex,
- Inline,
- Menu,
- MenuButton,
- MenuDivider,
- MenuItem,
- Text,
-} from '@sanity/ui'
+import {Card, Flex, Menu, MenuDivider} from '@sanity/ui'
import isEqual from 'lodash/isEqual'
import React, {useCallback, useId, useMemo} from 'react'
import styled from 'styled-components'
import {useTranslation} from '../../../../../i18n'
import {ORDERINGS} from '../definitions/orderings'
+import {Button, MenuButton, MenuItem} from '../../../../../../ui-components'
import {useSearchState} from '../contexts/search/useSearchState'
import type {SearchOrdering} from '../types'
@@ -55,13 +45,12 @@ function CustomMenuItem({ordering}: {ordering: SearchOrdering}) {
const isSelected = useMemo(() => isEqual(currentOrdering, ordering), [currentOrdering, ordering])
return (
-
+
)
}
@@ -85,22 +74,7 @@ export function SortMenu() {
-
-
-
-
-
-
-
-
- {t(currentMenuItem.titleKey)}
-
-
-
-
- }
+ button={}
id={menuButtonId || ''}
menu={
+
+ {fieldDefinition?.name}
+
)}
{/* Field description */}
{fieldDefinitionDescription && (
-
-
+
+
{truncateString(fieldDefinitionDescription, 256)}
@@ -106,7 +111,7 @@ export function FilterTooltip({
{/* Filter description */}
{filterDefinition?.description && (
-
+
{truncateString(filterDefinition.description, 256)}
)}
@@ -115,16 +120,16 @@ export function FilterTooltip({
{!documentTypesNarrowed.length && fieldDefinitionDocumentTypeTitles.length > 0 && (
-
+
-
+
{fieldDefinitionDocumentTypeTitles.length}
-
+
{fieldDefinitionDocumentTypeTitles.slice(0, MAX_VISIBLE_TYPES).join(', ')}
{fieldDefinitionDocumentTypeTitles?.length > MAX_VISIBLE_TYPES
? ` +${fieldDefinitionDocumentTypeTitles.length - MAX_VISIBLE_TYPES} more`
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemFilter.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemFilter.tsx
index dea885d2502..b2a4294c0c7 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemFilter.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemFilter.tsx
@@ -1,5 +1,11 @@
-import {Box, Button, ResponsiveMarginProps, ResponsivePaddingProps} from '@sanity/ui'
-import React, {useCallback, useEffect, useRef, useState} from 'react'
+import {
+ Box,
+ ResponsiveMarginProps,
+ ResponsivePaddingProps,
+ // eslint-disable-next-line no-restricted-imports
+ Button, // Button with specific styling and children.
+} from '@sanity/ui'
+import React, {useCallback} from 'react'
import {useSearchState} from '../../../../contexts/search/useSearchState'
import type {FilterMenuItemFilter} from '../../../../types'
import {getFilterKey} from '../../../../utils/filterUtils'
@@ -16,8 +22,6 @@ export const MenuItemFilter = React.memo(function MenuItemFilter({
onClose,
...rest
}: FilterMenuItemProps) {
- const [tooltipVisible, setTooltipVisible] = useState(false)
-
const {
dispatch,
state: {filters},
@@ -30,20 +34,6 @@ export const MenuItemFilter = React.memo(function MenuItemFilter({
const isAlreadyActive = !!filters.find((f) => getFilterKey(f) === getFilterKey(item.filter))
- const timeoutRef = useRef>()
-
- const handleMouseEnter = useCallback(() => {
- timeoutRef.current = setTimeout(() => setTooltipVisible(true), 500)
- }, [])
- const handleMouseLeave = useCallback(() => {
- setTooltipVisible(false)
- clearTimeout(timeoutRef.current)
- }, [])
-
- useEffect(() => {
- return () => clearTimeout(timeoutRef.current)
- }, [])
-
// Only enable tooltips if an associated field definition exists, or the filter has a valid description
const tooltipEnabled = !!(item.fieldDefinition || item.filterDefinition.description)
@@ -55,8 +45,6 @@ export const MenuItemFilter = React.memo(function MenuItemFilter({
justify="flex-start"
mode="bleed"
onClick={isAlreadyActive ? undefined : handleClick}
- onMouseEnter={handleMouseEnter}
- onMouseLeave={handleMouseLeave}
padding={0}
style={{position: 'relative', whiteSpace: 'normal', width: '100%'}}
tabIndex={-1}
@@ -65,7 +53,7 @@ export const MenuItemFilter = React.memo(function MenuItemFilter({
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemHeader.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemHeader.tsx
index c341ab678ab..6bcda11fdd1 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemHeader.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/addFilter/items/MenuItemHeader.tsx
@@ -1,4 +1,4 @@
-import {Box, Card, Label} from '@sanity/ui'
+import {Box, Card, Text} from '@sanity/ui'
import React from 'react'
import type {FilterMenuItemHeader} from '../../../../types'
@@ -9,10 +9,10 @@ interface MenuItemHeaderFields {
export const MenuItemHeader = React.memo(function MenuItemHeader({item}: MenuItemHeaderFields) {
return (
-
-
+
)
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterDetails.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterDetails.tsx
index 43aa5e50e09..b438253c315 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterDetails.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterDetails.tsx
@@ -9,21 +9,20 @@ import {FilterIcon} from './FilterIcon'
interface FilterDetailsProps {
filter: SearchFilter
- small?: boolean
}
-export function FilterDetails({filter, small = true}: FilterDetailsProps) {
+export function FilterDetails({filter}: FilterDetailsProps) {
const {
state: {definitions},
} = useSearchState()
const fieldDefinition = getFieldFromFilter(definitions.fields, filter)
return (
-
+
{/* Path */}
{fieldDefinition?.titlePath && fieldDefinition.titlePath?.length > 1 && (
-
+
{fieldDefinition.titlePath.slice(0, -1).map((pathTitle, index) => {
return (
-
+
-
+
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterPopoverContentHeader.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterPopoverContentHeader.tsx
index e972239d6e9..f5dcf36981b 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterPopoverContentHeader.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/common/FilterPopoverContentHeader.tsx
@@ -35,6 +35,8 @@ export const FilterPopoverContentHeader = forwardRef<
-
+
Document types
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugDocumentTypesNarrowed.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugDocumentTypesNarrowed.tsx
index 197c6f4fc8a..9d9fdd36774 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugDocumentTypesNarrowed.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugDocumentTypesNarrowed.tsx
@@ -10,7 +10,7 @@ export function DebugDocumentTypesNarrowed() {
return (
-
+
Document types (narrowed)
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterQuery.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterQuery.tsx
index 3f3b9fbf7e9..a0c4fd7fe3f 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterQuery.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterQuery.tsx
@@ -16,7 +16,7 @@ export function DebugFilterQuery() {
return (
-
+
Filter
{filter && (
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterValues.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterValues.tsx
index 2586ca69bf9..e832d1895e8 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterValues.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/debug/_DebugFilterValues.tsx
@@ -17,7 +17,7 @@ export function DebugFilterValues({filter}: DebugFilterValuesProps) {
return (
-
+
Filter
{fieldDefinition?.fieldPath && fieldPath: {fieldDefinition.fieldPath}
}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesButton.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesButton.tsx
index 551d759d1cd..9f5997368a5 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesButton.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesButton.tsx
@@ -1,24 +1,14 @@
-import {SelectIcon} from '@sanity/icons'
-import {Button, Placement, Popover, Theme, useClickOutside} from '@sanity/ui'
+import {ChevronDownIcon} from '@sanity/icons'
+import {Placement, useClickOutside} from '@sanity/ui'
import React, {useCallback, useMemo, useState} from 'react'
-import styled, {css} from 'styled-components'
import {POPOVER_RADIUS, POPOVER_VERTICAL_MARGIN} from '../../../constants'
import {useSearchState} from '../../../contexts/search/useSearchState'
import {documentTypesTruncated} from '../../../utils/documentTypesTruncated'
import {FilterPopoverWrapper} from '../common/FilterPopoverWrapper'
+import {Button, Popover} from '../../../../../../../../ui-components'
import {useTranslation} from '../../../../../../../i18n'
import {DocumentTypesPopoverContent} from './DocumentTypesPopoverContent'
-const StyledButton = styled(Button)(({theme}: {theme: Theme}) => {
- const {regular} = theme.sanity.fonts.text.weights
-
- return css`
- [data-ui='Text'] {
- font-weight: ${regular};
- }
- `
-})
-
const FALLBACK_PLACEMENTS: Placement[] = ['top-start', 'bottom-start']
export function DocumentTypesButton() {
@@ -56,15 +46,13 @@ export function DocumentTypesButton() {
radius={POPOVER_RADIUS}
ref={setPopoverElement}
>
-
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesPopoverContent.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesPopoverContent.tsx
index 3b436340d2d..10dca521ad2 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesPopoverContent.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/DocumentTypesPopoverContent.tsx
@@ -1,5 +1,5 @@
import {Schema} from '@sanity/types'
-import {Box, Button, Flex, Label, MenuDivider, Stack, Text} from '@sanity/ui'
+import {Box, Flex, MenuDivider, Stack, Text} from '@sanity/ui'
import {partition} from 'lodash'
import React, {useCallback, useMemo, useRef, useState} from 'react'
import styled from 'styled-components'
@@ -14,6 +14,7 @@ import type {SearchableType} from '../../../../../../../search'
import {useSearchState} from '../../../contexts/search/useSearchState'
import type {DocumentTypeMenuItem} from '../../../types'
import {getSelectableOmnisearchTypes} from '../../../utils/selectors'
+import {Button} from '../../../../../../../../ui-components'
import {FilterPopoverContentHeader} from '../common/FilterPopoverContentHeader'
import {useTranslation} from '../../../../../../../i18n'
import {DocumentTypeFilterItem} from './items/DocumentTypeFilterItem'
@@ -92,10 +93,10 @@ export function DocumentTypesPopoverContent() {
}
if (item.type === 'header') {
return (
-
-
+
)
}
@@ -187,10 +188,8 @@ function ClearButton({
aria-label={t('search.action.clear-type-filters-aria-label')}
data-name="type-filter-button"
disabled={selectedTypes.length === 0}
- fontSize={1}
mode="bleed"
onClick={onClick}
- padding={3}
text={t('search.action.clear-type-filters-label')}
tone="primary"
/>
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/items/DocumentTypeFilterItem.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/items/DocumentTypeFilterItem.tsx
index c14e6c0ddef..d91892b2f79 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/items/DocumentTypeFilterItem.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/documentTypes/items/DocumentTypeFilterItem.tsx
@@ -1,8 +1,9 @@
import {CheckmarkIcon} from '@sanity/icons'
-import {Box, Button, ResponsiveMarginProps, ResponsivePaddingProps} from '@sanity/ui'
+import {Box, ResponsiveMarginProps, ResponsivePaddingProps} from '@sanity/ui'
import React, {useCallback} from 'react'
import type {SearchableType} from '../../../../../../../../search'
import {useSearchState} from '../../../../contexts/search/useSearchState'
+import {Button} from '../../../../../../../../../ui-components'
interface DocumentTypeFilterItemProps extends ResponsiveMarginProps, ResponsivePaddingProps {
selected: boolean
@@ -35,13 +36,13 @@ export const DocumentTypeFilterItem = React.memo(function TypeFilterItem({
return (
-
+
{t('search.error.display-filter-title')}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/FilterForm.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/FilterForm.tsx
index 1f4138a1665..920a4a78175 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/FilterForm.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/FilterForm.tsx
@@ -1,7 +1,8 @@
import {TrashIcon} from '@sanity/icons'
-import {Box, Button, Card, ErrorBoundary, Flex, Stack, Text} from '@sanity/ui'
+import {Box, Card, ErrorBoundary, Flex, Stack, Text} from '@sanity/ui'
import React, {ErrorInfo, useCallback, useState} from 'react'
import FocusLock from 'react-focus-lock'
+import {Button} from '../../../../../../../../ui-components'
import {supportsTouch} from '../../../../../../../util'
import {useSearchState} from '../../../contexts/search/useSearchState'
import {getFilterDefinition} from '../../../definitions/filters'
@@ -83,23 +84,17 @@ export function FilterForm({filter}: FilterFormProps) {
-
-
+
+
{fullscreen && (
)}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/OperatorsMenuButton.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/OperatorsMenuButton.tsx
index 29258c30fb4..5684ce65d1b 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/OperatorsMenuButton.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/OperatorsMenuButton.tsx
@@ -1,7 +1,8 @@
-import {SelectIcon} from '@sanity/icons'
-import {Box, Button, Flex, Inline, Menu, MenuButton, MenuDivider, MenuItem, Text} from '@sanity/ui'
-import React, {createElement, useCallback, useId} from 'react'
+import {ChevronDownIcon} from '@sanity/icons'
+import {Inline, Menu, MenuDivider} from '@sanity/ui'
+import React, {useCallback, useId} from 'react'
import {useSearchState} from '../../../contexts/search/useSearchState'
+import {Button, MenuButton, MenuItem} from '../../../../../../../../ui-components'
import {getFilterDefinition} from '../../../definitions/filters'
import {getOperatorDefinition, SearchOperatorDefinition} from '../../../definitions/operators'
import type {SearchFilter} from '../../../types'
@@ -26,20 +27,13 @@ function CustomMenuItem({
const {t} = useTranslation()
return (
-
+
)
}
@@ -68,20 +62,7 @@ export function OperatorsMenuButton({filter, operator}: OperatorsMenuButtonProps
return (
-
-
- {t(operator.nameKey)}
-
-
-
-
-
-
-
-
- }
+ button={}
id={menuButtonId || ''}
menu={
-
+
{t('search.error.no-valid-asset-source-title')}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/FileReferencePreview.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/FileReferencePreview.tsx
index c6e97e9d678..a56f31d05f5 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/FileReferencePreview.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/FileReferencePreview.tsx
@@ -1,6 +1,6 @@
import {BinaryDocumentIcon} from '@sanity/icons'
import type {FileAsset, ReferenceValue} from '@sanity/types'
-import {Card, Flex, LabelSkeleton, Stack, Text} from '@sanity/ui'
+import {Card, Flex, Stack, Text, TextSkeleton} from '@sanity/ui'
import React, {useCallback} from 'react'
import {formatBytes} from '../../../../../../../../../../form/inputs/common/helper'
import {observeFileAsset} from '../../../../../../../../../../form/studio/inputs/client-adapters/assets'
@@ -29,6 +29,7 @@ export function FileReferencePreview({reference}: FileReferencePreviewProps) {
}
function FilePreview({asset}: {asset: FileAsset}) {
+ // todo: consider replacing with
return (
@@ -38,7 +39,7 @@ function FilePreview({asset}: {asset: FileAsset}) {
-
+
{asset?.originalFilename || asset._id}
@@ -60,8 +61,8 @@ function FileSkeleton() {
-
-
+
+
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/ImageReferencePreview.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/ImageReferencePreview.tsx
index 3aa792f8f6f..afdcffb55bc 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/ImageReferencePreview.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/asset/preview/ImageReferencePreview.tsx
@@ -1,10 +1,11 @@
import type {ImageAsset, ReferenceValue} from '@sanity/types'
-import {Card, Flex, Spinner} from '@sanity/ui'
+import {Card} from '@sanity/ui'
import React, {useCallback, useState} from 'react'
import styled from 'styled-components'
import {observeImageAsset} from '../../../../../../../../../../form/studio/inputs/client-adapters/assets'
import {WithReferencedAsset} from '../../../../../../../../../../form/utils/WithReferencedAsset'
import {useDocumentPreviewStore} from '../../../../../../../../../../store'
+import {LoadingBlock} from '../../../../../../../../../../components/loadingBlock'
interface ImageReferencePreviewProps {
reference: ReferenceValue
@@ -25,12 +26,6 @@ const Image = styled.img`
object-fit: contain;
`
-const SpinnerFlex = styled(Flex)`
- height: 100%;
- position: absolute;
- width: 100%;
-`
-
export function ImageReferencePreview({reference}: ImageReferencePreviewProps) {
const documentPreviewStore = useDocumentPreviewStore()
const observeAsset = useCallback(
@@ -51,11 +46,7 @@ function ImagePreview({asset}: {asset: ImageAsset}) {
return (
- {!loaded && (
-
-
-
- )}
+ {!loaded && }
)
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/ParsedDateTextInput.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/ParsedDateTextInput.tsx
index 4dc0a529d51..540f76af11e 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/ParsedDateTextInput.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/ParsedDateTextInput.tsx
@@ -1,6 +1,3 @@
-import {hues} from '@sanity/color'
-import {ErrorOutlineIcon} from '@sanity/icons'
-import {Flex, Text, Theme, Tooltip} from '@sanity/ui'
import {format, isValid, parse} from 'date-fns'
import React, {
ChangeEvent,
@@ -11,8 +8,8 @@ import React, {
useMemo,
useState,
} from 'react'
-import styled, {css} from 'styled-components'
-import {Translate, useTranslation} from '../../../../../../../../../i18n'
+import {Tooltip} from '../../../../../../../../../../ui-components'
+import {useTranslation} from '../../../../../../../../../i18n'
import {CustomTextInput} from '../../../../common/CustomTextInput'
import {getDateISOString} from './utils/getDateISOString'
@@ -51,16 +48,6 @@ const FORMAT: Record<
},
}
-const Emphasis = styled.span(({theme}: {theme: Theme}) => {
- return css`
- font-weight: ${theme.sanity.fonts.text.weights.medium};
- `
-})
-
-const IconTextCritical = styled(Text)`
- color: ${hues.red[500].hex};
-`
-
export function ParsedDateTextInput({
isDateTime,
onChange,
@@ -161,44 +148,25 @@ export function ParsedDateTextInput({
return (
-
-
-
-
-
-
-
- }
+ content={t('calendar.error.must-be-in-format', {
+ exampleDate: isDateTimeFormat ? FORMAT.datetime.exampleDate : FORMAT.date.exampleDate,
+ })}
disabled={!customValidity}
- padding={3}
placement="top"
portal
>
{/* HACK: Wrapping element required for to function */}
-
-
-
+
)
}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/DatePicker.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/DatePicker.tsx
index c2e7bc48006..674a0570b01 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/DatePicker.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/DatePicker.tsx
@@ -1,5 +1,4 @@
import React, {useCallback} from 'react'
-import {useSearchState} from '../../../../../../contexts/search/useSearchState'
import {Calendar} from './calendar/Calendar'
interface DatePickerProps {
@@ -11,10 +10,6 @@ interface DatePickerProps {
}
export function DatePicker({date, endDate, onChange, selectRange, selectTime}: DatePickerProps) {
- const {
- state: {fullscreen},
- } = useSearchState()
-
const handleSelect = useCallback(
(dates: {date: Date | null; endDate?: Date | null}) => {
onChange(dates)
@@ -26,7 +21,6 @@ export function DatePicker({date, endDate, onChange, selectRange, selectTime}: D
-
-type Props = Omit & {
- onChange?: (
- event: React.FocusEvent | React.ChangeEvent,
- ) => void
-}
-
-/**
- * A TextInput that only emit onChange when it has to
- * By default it will only emit onChange when: 1) user hits enter or 2) user leaves the
- * field (e.g. onBlur) and the input value at this time is different from the given `value` prop
- */
-export const LazyTextInput = React.forwardRef(function LazyTextInput(
- {onChange, onBlur, onKeyPress, value, ...rest}: Props,
- forwardedRef: React.ForwardedRef,
-) {
- const [inputValue, setInputValue] = React.useState()
-
- const {fontSize} = useCalendar()
-
- const handleChange = React.useCallback((event: any) => {
- setInputValue(event.currentTarget.value)
- }, [])
-
- const checkEvent = React.useCallback(
- (event: any) => {
- const currentValue = event.currentTarget.value
- if (currentValue !== `${value}`) {
- if (onChange) {
- onChange(event)
- }
- }
- setInputValue(undefined)
- },
- [onChange, value],
- )
-
- const handleBlur = React.useCallback(
- (e: any) => {
- checkEvent(e)
- if (onBlur) {
- onBlur(e)
- }
- },
- [checkEvent, onBlur],
- )
-
- const handleKeyPress = React.useCallback(
- (e: React.KeyboardEvent) => {
- if (e.key === 'Enter') {
- checkEvent(e)
- }
- if (onKeyPress) {
- onKeyPress(e)
- }
- },
- [checkEvent, onKeyPress],
- )
-
- return (
-
- )
-})
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/Calendar.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/Calendar.tsx
index fe973982f4f..e79f6fcc6b1 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/Calendar.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/Calendar.tsx
@@ -10,7 +10,6 @@ import {ARROW_KEYS} from './constants'
type CalendarProps = Omit, 'onSelect'> & {
date?: Date
endDate?: Date
- fontSize: number
onSelect: ({date, endDate}: {date: Date | null; endDate?: Date | null}) => void
selectRange?: boolean
selectTime?: boolean
@@ -32,7 +31,7 @@ const PRESERVE_FOCUS_ELEMENT = (
)
export function Calendar(props: CalendarProps) {
- const {date, endDate, fontSize, onSelect, selectRange, selectTime} = props
+ const {date, endDate, onSelect, selectRange, selectTime} = props
const [calendarElement, setCalendarElement] = useState(null)
const [selectEndValue, setSelectEndValue] = useState(false)
@@ -184,7 +183,6 @@ export function Calendar(props: CalendarProps) {
date,
endDate,
focusedDate,
- fontSize,
selectRange,
selectTime,
firstWeekDay,
@@ -194,11 +192,7 @@ export function Calendar(props: CalendarProps) {
{/* Select month and year */}
-
+
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarDay.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarDay.tsx
index c28309fec19..c9d65ce63f8 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarDay.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarDay.tsx
@@ -52,13 +52,7 @@ export function CalendarDay({date, onSelect}: CalendarDayProps) {
onSelect(date)
}, [date, onSelect])
- const {
- date: selectedDate,
- endDate: selectedEndDate,
- focusedDate,
- fontSize,
- selectRange,
- } = useCalendar()
+ const {date: selectedDate, endDate: selectedEndDate, focusedDate, selectRange} = useCalendar()
const isSelected = selectedDate && isSameDay(date, selectedDate)
const isStartDate = selectRange && selectedDate && isSameDay(date, selectedDate)
@@ -89,7 +83,8 @@ export function CalendarDay({date, onSelect}: CalendarDayProps) {
data-within-range={isWithinRange ? true : undefined}
forwardedAs="button"
onClick={handleClick}
- padding={3}
+ paddingX={3}
+ paddingY={2}
radius={2}
role="button"
selected={isSelected || isStartDate || isEndDate}
@@ -110,8 +105,8 @@ export function CalendarDay({date, onSelect}: CalendarDayProps) {
{date.getDate()}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarHeader.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarHeader.tsx
index 325468615d3..d495cb4b841 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarHeader.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarHeader.tsx
@@ -1,13 +1,13 @@
import {upperFirst} from 'lodash'
import {ChevronLeftIcon, ChevronRightIcon} from '@sanity/icons'
-import {Box, Button, Flex, Inline, Text} from '@sanity/ui'
+import {Flex, Inline, Text} from '@sanity/ui'
import React, {useCallback} from 'react'
+import {Button} from '../../../../../../../../../../../../ui-components'
import {useTranslation} from '../../../../../../../../../../../i18n'
import {useDateTimeFormat} from '../../../../../../../../../../../hooks/useDateTimeFormat'
import {useCalendar} from './contexts/useDatePicker'
export function CalendarHeader(props: {
- fontSize?: number
moveFocusedDate: (by: number) => void
onNowClick: () => void
}) {
@@ -15,7 +15,7 @@ export function CalendarHeader(props: {
const monthFormatter = useDateTimeFormat({month: 'long', year: 'numeric'})
const {focusedDate} = useCalendar()
- const {fontSize, moveFocusedDate, onNowClick} = props
+ const {moveFocusedDate, onNowClick} = props
const handlePrevMonthClick = useCallback(() => moveFocusedDate(-1), [moveFocusedDate])
@@ -25,29 +25,30 @@ export function CalendarHeader(props: {
{/* Technically not correct to simply uppercase first here, but simplifying for now */}
- {upperFirst(monthFormatter.format(focusedDate))}
+
+ {upperFirst(monthFormatter.format(focusedDate))}
+
-
+
-
+
)
}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarMonth.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarMonth.tsx
index 34301ad4f16..f1364c2cb5e 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarMonth.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarMonth.tsx
@@ -25,15 +25,15 @@ const CustomGrid = styled(Grid)`
`
export function CalendarMonth({hidden, onSelect}: CalendarMonthProps) {
- const {focusedDate, fontSize, firstWeekDay} = useCalendar()
+ const {focusedDate, firstWeekDay} = useCalendar()
const {t} = useTranslation()
return (
-
+
{WEEK_DAY_NAME_KEYS[firstWeekDay].map((weekdayDay) => (
-
+
{t(weekdayDay)}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/contexts/CalendarContext.ts b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/contexts/CalendarContext.ts
index cc12173baf7..ba8a02ab403 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/contexts/CalendarContext.ts
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/contexts/CalendarContext.ts
@@ -4,7 +4,6 @@ export interface CalendarContextValue {
date?: Date
endDate?: Date
focusedDate: Date
- fontSize: number
selectRange?: boolean
selectTime?: boolean
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/reference/Reference.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/reference/Reference.tsx
index 154c552b6bc..bd336269da1 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/reference/Reference.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/reference/Reference.tsx
@@ -1,6 +1,7 @@
import {isArraySchemaType, isReferenceSchemaType, ReferenceValue} from '@sanity/types'
-import {Box, Button, Card, Stack} from '@sanity/ui'
+import {Box, Card, Stack} from '@sanity/ui'
import React, {useCallback, useMemo} from 'react'
+import {Button} from '../../../../../../../../../../ui-components'
import {useSchema} from '../../../../../../../../../hooks'
import {SearchableType} from '../../../../../../../../../search'
import {useSearchState} from '../../../../../contexts/search/useSearchState'
@@ -17,7 +18,7 @@ export function SearchFilterReferenceInput({
}: OperatorInputComponentProps) {
const {
onClose,
- state: {documentTypesNarrowed, fullscreen},
+ state: {documentTypesNarrowed},
} = useSearchState()
const schema = useSchema()
const {t} = useTranslation()
@@ -68,14 +69,13 @@ export function SearchFilterReferenceInput({
)
}, [])
@@ -156,7 +157,6 @@ export const ReferenceAutocomplete = forwardRef(function ReferenceAutocomplete(
const hasResults = hits && hits.length > 0
return (
@@ -177,6 +177,7 @@ export const ReferenceAutocomplete = forwardRef(function ReferenceAutocomplete(
)}
}
+ fallbackPlacements={['bottom', 'bottom-end']}
matchReferenceWidth
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
diff --git a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/string/StringList.tsx b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/string/StringList.tsx
index d40305c413a..45a573ab7ed 100644
--- a/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/string/StringList.tsx
+++ b/packages/sanity/src/core/studio/components/navbar/search/components/filters/filter/inputs/string/StringList.tsx
@@ -1,6 +1,6 @@
-import {SelectIcon} from '@sanity/icons'
+import {ChevronDownIcon} from '@sanity/icons'
import {isTitledListValue, StringOptions, TitledListValue} from '@sanity/types'
-import {Box, Button, Code, Flex, Menu, MenuButton, MenuItem, Stack, Text} from '@sanity/ui'
+import {Menu} from '@sanity/ui'
import {capitalize, uniq} from 'lodash'
import React, {useCallback, useId, useMemo} from 'react'
import {useSchema} from '../../../../../../../../../hooks'
@@ -8,6 +8,7 @@ import {isNonNullable} from '../../../../../../../../../util'
import {useSearchState} from '../../../../../contexts/search/useSearchState'
import {OperatorInputComponentProps} from '../../../../../definitions/operators/operatorTypes'
import {getSchemaField} from '../../../../../utils/getSchemaField'
+import {Button, MenuButton, MenuItem} from '../../../../../../../../../../ui-components'
import {useTranslation} from '../../../../../../../../../i18n'
interface TitledListValueGroup extends Omit