diff --git a/packages/core/components/Loader/Loader.tsx b/packages/core/components/Loader/Loader.tsx index 87f9608b8..d5877f6d0 100644 --- a/packages/core/components/Loader/Loader.tsx +++ b/packages/core/components/Loader/Loader.tsx @@ -1,17 +1,22 @@ import React, { useEffect, useRef } from 'react' import './loader.styles.css' +// these coorespond to bootstrap classes +// https://getbootstrap.com/docs/4.2/components/spinners/ +type SpinnerType = 'text-primary' | 'text-secondary' + type LoaderProps = { fullScreen?: boolean + spinnerType?: SpinnerType } -const Spinner = () => ( -
+const Spinner = ({ spinnerType }: { spinnerType: SpinnerType }) => ( +
Loading...
) -const Loader: React.FC = ({ fullScreen = false }) => { +const Loader: React.FC = ({ fullScreen = false, spinnerType }) => { const backgroundRef = useRef(null) useEffect(() => { @@ -23,10 +28,10 @@ const Loader: React.FC = ({ fullScreen = false }) => { return fullScreen ? (
- +
) : ( - + ) } diff --git a/packages/core/components/MultiSelect/MultiSelect.tsx b/packages/core/components/MultiSelect/MultiSelect.tsx index b68a72a20..01b4df4d6 100644 --- a/packages/core/components/MultiSelect/MultiSelect.tsx +++ b/packages/core/components/MultiSelect/MultiSelect.tsx @@ -4,6 +4,7 @@ import Icon from '../ui/Icon' import './multiselect.styles.css' import { UpdateFieldFunc } from '../../types/UpdateFieldFunc' +import Loader from '../Loader' interface Option { value: string | number @@ -20,6 +21,7 @@ interface MultiSelectProps { selected?: (string | number)[] limit?: number tooltip?: React.ReactNode + loading?: boolean } const MultiSelect: React.FC = ({ @@ -31,7 +33,8 @@ const MultiSelect: React.FC = ({ updateField, selected = [], limit, - tooltip + tooltip, + loading }) => { const preselectedItems = options.filter(opt => selected.includes(opt.value)).slice(0, limit) const [selectedItems, setSelectedItems] = useState(preselectedItems) @@ -90,11 +93,12 @@ const MultiSelect: React.FC = ({
{ - if (!selectedItems.length) { + if (!selectedItems.length && !loading) { setExpanded(true) } }} className='selected' + aria-disabled={loading} > {selectedItems.length ? ( selectedItems.map(item => ( @@ -115,7 +119,7 @@ const MultiSelect: React.FC = ({
)) ) : ( - - Select - + {loading ? 'Loading...' : '- Select -'} )}
+ {loading && } {!!limit && ( @@ -140,6 +145,7 @@ const MultiSelect: React.FC = ({ )} +