import { FiltersMap, TransitionState } from '@wix/bex-core'; import { observer } from 'mobx-react-lite'; import React, { useRef, useState } from 'react'; import { SwitchTransition } from 'react-transition-group'; import { Box, Divider } from '@wix/design-system'; import { ChevronLeftLarge } from '@wix/wix-ui-icons-common'; import { CollectionSearch } from '../CollectionSearch'; import { EditorXLogo } from '../EditorXLogo'; import { WixLogo } from '../WixLogo'; import { PickerStandaloneLayoutTitles } from './PickerStandaloneLayoutTitles'; import { Collapse } from '../Collapse'; import { Fade } from '../Fade'; import { PickerStandaloneState } from '../../state'; import { ExpandableSearch } from '../ExpandableSearch'; export interface PickerStandaloneLayoutHeaderProps< T, F extends FiltersMap = FiltersMap, > { state: PickerStandaloneState; hideSearch?: boolean; } function _PickerStandaloneLayoutHeader( props: PickerStandaloneLayoutHeaderProps, ) { const { state, hideSearch } = props; const { picker, logoType, isMobileView, isDuringSearch } = state; const { collection, isScrollTop } = picker; const searchRef = useRef(); const onSearchFocus = () => { state.setIsDuringSearch(true); }; const onSearchBlur = () => { if (collection.query.search.isEmpty) { state.setIsDuringSearch(false); } }; const onBackClicked = async () => { searchRef.current?.focus(); await collection.clearSearch(); searchRef.current?.blur(); }; const { headerProps, header, headerDivider, titleSearchContainerProps, titleDivider, } = isMobileView ? { headerProps: { padding: '12px 24px', align: 'space-between' as const, }, header: ( <>
{isDuringSearch ? ( ) : ( {logoType === 'editorx' ? ( ) : ( )} )}
{ searchRef.current = input; }} /> ), headerDivider: undefined, titleSearchContainerProps: { paddingBottom: !isScrollTop && !collection.result.isEmpty ? 0 : 'SP2', }, titleDivider: !isScrollTop && !collection.result.isEmpty && ( ), } : { headerProps: { padding: '24px 30px', align: 'center' as const, }, header: ( {logoType === 'editorx' ? ( ) : ( )} ), headerDivider: , titleSearchContainerProps: { paddingTop: 'SP4', paddingBottom: 'SP3', gap: 'SP3', }, titleDivider: !hideSearch && ( ), }; const [collapse] = useState(() => new TransitionState(true)); return ( <> {header} {headerDivider} {titleDivider} ); } export const PickerStandaloneLayoutHeader = observer( _PickerStandaloneLayoutHeader, );