: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
import React, { useRef, useState, useEffect } from 'react';
import { styled } from '@linaria/react';
} from '../UIComponents/colors';
import UISpinner from '../UIComponents/UISpinner';
import LoadState, { LoadStateType } from '../enums/loadState';
const Container = styled.div`
font-family: 'Lexend Deca', Helvetica, Arial, sans-serif;
interface IControlContainerProps {
const ControlContainer = styled.div<IControlContainerProps>`
background-color: hsl(0, 0%, 100%);
border-color: hsl(0, 0%, 80%);
border-width: ${props => (props.focused ? '0' : '1px')};
justify-content: space-between;
props.focused ? `0 0 0 2px ${CALYPSO_MEDIUM}` : 'none'};
border-color: hsl(0, 0%, 70%);
const ValueContainer = styled.div`
const Placeholder = styled.div`
transform: translateY(-50%);
const SingleValue = styled.div`
max-width: calc(100% - 8px);
transform: translateY(-50%);
const IndicatorContainer = styled.div`
const DropdownIndicator = styled.div`
border-top: 8px solid ${CALYPSO};
border-left: 6px solid transparent;
border-right: 6px solid transparent;
const InputContainer = styled.div`
const Input = styled.input`
background: rgba(0, 0, 0, 0) none repeat scroll 0px center;
outline: currentcolor none 0px;
const InputShadow = styled.div`
const MenuContainer = styled.div`
box-shadow: 0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1);
const MenuList = styled.div`
const MenuGroup = styled.div`
const MenuGroupHeader = styled.div`
text-transform: uppercase;
interface IMenuItemProps {
const MenuItem = styled.div<IMenuItemProps>`
background-color: ${props =>
props.selected ? CALYPSO_MEDIUM : 'transparent'};
color: ${props => (props.selected ? '#fff' : 'inherit')};
background-color: ${props =>
props.selected ? CALYPSO_MEDIUM : CALYPSO_LIGHT};
interface IAsyncSelectProps {
export default function AsyncSelect({
const inputEl = useRef<HTMLInputElement>(null);
const inputShadowEl = useRef<HTMLDivElement>(null);
const [isFocused, setFocus] = useState(false);
const [loadState, setLoadState] = useState<LoadStateType>(
const [localValue, setLocalValue] = useState('');
const [options, setOptions] = useState(defaultOptions);
inputShadowEl.current ? inputShadowEl.current.clientWidth + 10 : 2
if (loadOptions && loadState === LoadState.NotLoaded) {
loadOptions('', (result: any) => {
setLoadState(LoadState.Idle);
}, [loadOptions, loadState]);
const renderItems = (items: any[] = [], parentKey?: number) => {
return items.map((item, index) => {
<MenuGroup key={`async-select-item-${index}`}>
<MenuGroupHeader id={`${index}-heading`}>
<div>{renderItems(item.options, index)}</div>
const key = `async-select-item-${
parentKey !== undefined ? `${parentKey}-${index}` : index
selected={value && item.value === value.value}
id="leadin-async-selector"
<Placeholder>{placeholder}</Placeholder>
<SingleValue>{value.label}</SingleValue>
setLocalValue(e.target.value);
setLoadState(LoadState.Loading);
loadOptions(e.target.value, (result: any) => {
setLoadState(LoadState.Idle);
<InputShadow ref={inputShadowEl}>{localValue}</InputShadow>
{loadState === LoadState.Loading && <UISpinner />}
<MenuList>{renderItems(options)}</MenuList>