@atlaskit/link-datasource 1.26.2 → 1.26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/ui/common/modal/basic-search-input/index.js +9 -18
- package/dist/cjs/ui/common/modal/popup-select/index.js +217 -0
- package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/errorMessage.js +3 -3
- package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/index.js +6 -5
- package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/messages.js +5 -0
- package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/noOptionsMessage.js +3 -3
- package/dist/cjs/ui/common/modal/popup-select/menu-list/showMoreButton.js +36 -0
- package/dist/cjs/ui/common/modal/popup-select/messages.js +19 -0
- package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/trigger.js +12 -13
- package/dist/cjs/ui/common/modal/popup-select/types.js +5 -0
- package/dist/cjs/ui/confluence-search-modal/basic-filters/index.js +22 -0
- package/dist/cjs/ui/confluence-search-modal/confluence-search-container/index.js +18 -3
- package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +27 -163
- package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.js +0 -15
- package/dist/cjs/ui/jira-issues-modal/jira-search-container/index.js +2 -1
- package/dist/es2019/ui/common/modal/basic-search-input/index.js +2 -10
- package/dist/es2019/ui/common/modal/popup-select/index.js +170 -0
- package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/errorMessage.js +3 -3
- package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/index.js +6 -5
- package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/messages.js +5 -0
- package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/noOptionsMessage.js +3 -3
- package/dist/es2019/ui/common/modal/popup-select/menu-list/showMoreButton.js +29 -0
- package/dist/es2019/ui/common/modal/popup-select/messages.js +13 -0
- package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/trigger.js +10 -11
- package/dist/es2019/ui/common/modal/popup-select/types.js +1 -0
- package/dist/es2019/ui/confluence-search-modal/basic-filters/index.js +13 -0
- package/dist/es2019/ui/confluence-search-modal/confluence-search-container/index.js +19 -4
- package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +25 -145
- package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.js +0 -15
- package/dist/es2019/ui/jira-issues-modal/jira-search-container/index.js +2 -1
- package/dist/esm/ui/common/modal/basic-search-input/index.js +2 -10
- package/dist/esm/ui/common/modal/popup-select/index.js +207 -0
- package/dist/esm/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/errorMessage.js +3 -3
- package/dist/esm/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/index.js +6 -5
- package/dist/esm/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/messages.js +5 -0
- package/dist/esm/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/noOptionsMessage.js +3 -3
- package/dist/esm/ui/common/modal/popup-select/menu-list/showMoreButton.js +26 -0
- package/dist/esm/ui/common/modal/popup-select/messages.js +13 -0
- package/dist/esm/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/trigger.js +12 -13
- package/dist/esm/ui/common/modal/popup-select/types.js +1 -0
- package/dist/esm/ui/confluence-search-modal/basic-filters/index.js +15 -0
- package/dist/esm/ui/confluence-search-modal/confluence-search-container/index.js +19 -4
- package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/index.js +27 -163
- package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.js +0 -15
- package/dist/esm/ui/jira-issues-modal/jira-search-container/index.js +2 -1
- package/dist/types/analytics/generated/analytics.types.d.ts +6 -6
- package/dist/types/ui/common/modal/basic-search-input/index.d.ts +1 -0
- package/dist/types/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/control.d.ts +1 -1
- package/dist/{types-ts4.5/ui/jira-issues-modal/basic-filters/ui/async-popup-select → types/ui/common/modal/popup-select}/dropdownIndicator.d.ts +1 -1
- package/dist/types/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/formatOptionLabel.d.ts +1 -1
- package/dist/types/ui/common/modal/popup-select/index.d.ts +21 -0
- package/dist/types/ui/common/modal/popup-select/menu-list/errorMessage.d.ts +6 -0
- package/dist/types/ui/common/modal/popup-select/menu-list/index.d.ts +15 -0
- package/dist/{types-ts4.5/ui/jira-issues-modal/basic-filters/ui → types/ui/common/modal/popup-select}/menu-list/messages.d.ts +5 -0
- package/dist/types/ui/common/modal/popup-select/menu-list/noOptionsMessage.d.ts +5 -0
- package/dist/{types-ts4.5/ui/jira-issues-modal/basic-filters/ui/async-popup-select → types/ui/common/modal/popup-select/menu-list}/showMoreButton.d.ts +2 -1
- package/dist/types/ui/common/modal/popup-select/messages.d.ts +12 -0
- package/dist/types/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/trigger.d.ts +3 -2
- package/dist/types/ui/common/modal/popup-select/types.d.ts +22 -0
- package/dist/types/ui/confluence-search-modal/basic-filters/index.d.ts +5 -0
- package/dist/types/ui/jira-issues-modal/basic-filters/types.d.ts +0 -2
- package/dist/types/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.d.ts +0 -15
- package/dist/types-ts4.5/analytics/generated/analytics.types.d.ts +6 -6
- package/dist/types-ts4.5/ui/common/modal/basic-search-input/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/control.d.ts +1 -1
- package/dist/{types/ui/jira-issues-modal/basic-filters/ui/async-popup-select → types-ts4.5/ui/common/modal/popup-select}/dropdownIndicator.d.ts +1 -1
- package/dist/types-ts4.5/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/formatOptionLabel.d.ts +1 -1
- package/dist/types-ts4.5/ui/common/modal/popup-select/index.d.ts +21 -0
- package/dist/types-ts4.5/ui/common/modal/popup-select/menu-list/errorMessage.d.ts +6 -0
- package/dist/types-ts4.5/ui/common/modal/popup-select/menu-list/index.d.ts +15 -0
- package/dist/{types/ui/jira-issues-modal/basic-filters/ui → types-ts4.5/ui/common/modal/popup-select}/menu-list/messages.d.ts +5 -0
- package/dist/types-ts4.5/ui/common/modal/popup-select/menu-list/noOptionsMessage.d.ts +5 -0
- package/dist/{types/ui/jira-issues-modal/basic-filters/ui/async-popup-select → types-ts4.5/ui/common/modal/popup-select/menu-list}/showMoreButton.d.ts +2 -1
- package/dist/types-ts4.5/ui/common/modal/popup-select/messages.d.ts +12 -0
- package/dist/types-ts4.5/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/trigger.d.ts +3 -2
- package/dist/types-ts4.5/ui/common/modal/popup-select/types.d.ts +22 -0
- package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/types.d.ts +0 -2
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/async-popup-select/messages.d.ts +0 -15
- package/package.json +6 -3
- package/dist/cjs/ui/jira-issues-modal/basic-filters/ui/async-popup-select/showMoreButton.js +0 -22
- package/dist/es2019/ui/jira-issues-modal/basic-filters/ui/async-popup-select/showMoreButton.js +0 -17
- package/dist/esm/ui/jira-issues-modal/basic-filters/ui/async-popup-select/showMoreButton.js +0 -15
- package/dist/types/ui/jira-issues-modal/basic-filters/ui/menu-list/errorMessage.d.ts +0 -8
- package/dist/types/ui/jira-issues-modal/basic-filters/ui/menu-list/index.d.ts +0 -5
- package/dist/types/ui/jira-issues-modal/basic-filters/ui/menu-list/noOptionsMessage.d.ts +0 -6
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/menu-list/errorMessage.d.ts +0 -8
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/menu-list/index.d.ts +0 -5
- package/dist/types-ts4.5/ui/jira-issues-modal/basic-filters/ui/menu-list/noOptionsMessage.d.ts +0 -6
- /package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/control.js +0 -0
- /package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/dropdownIndicator.js +0 -0
- /package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/footer.js +0 -0
- /package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/formatOptionLabel.js +0 -0
- /package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/loadingMessage.js +0 -0
- /package/dist/cjs/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/selectMessage.js +0 -0
- /package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/control.js +0 -0
- /package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/dropdownIndicator.js +0 -0
- /package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/footer.js +0 -0
- /package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/formatOptionLabel.js +0 -0
- /package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/loadingMessage.js +0 -0
- /package/dist/es2019/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/selectMessage.js +0 -0
- /package/dist/esm/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/control.js +0 -0
- /package/dist/esm/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/dropdownIndicator.js +0 -0
- /package/dist/esm/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/footer.js +0 -0
- /package/dist/esm/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/formatOptionLabel.js +0 -0
- /package/dist/esm/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/loadingMessage.js +0 -0
- /package/dist/esm/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/selectMessage.js +0 -0
- /package/dist/types/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/footer.d.ts +0 -0
- /package/dist/types/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/loadingMessage.d.ts +0 -0
- /package/dist/types/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/selectMessage.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{jira-issues-modal/basic-filters/ui/async-popup-select → common/modal/popup-select}/footer.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/loadingMessage.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{jira-issues-modal/basic-filters/ui → common/modal/popup-select}/menu-list/selectMessage.d.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const asyncPopupSelectMessages = defineMessages({
|
|
3
|
+
selectPlaceholder: {
|
|
4
|
+
id: 'linkDataSource.basic-filter.dropdown.select.placeholder',
|
|
5
|
+
description: 'Placeholder text to be displayed for the search input box.',
|
|
6
|
+
defaultMessage: 'Search'
|
|
7
|
+
},
|
|
8
|
+
paginationDetails: {
|
|
9
|
+
id: 'linkDataSource.basic-filter.footer.pagination-details',
|
|
10
|
+
description: 'Text to indicate page count and total count information.',
|
|
11
|
+
defaultMessage: '{currentDisplayCount} of {totalCount}'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback } from 'react';
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
|
-
import { FormattedMessage } from 'react-intl-next';
|
|
4
3
|
import Badge from '@atlaskit/badge';
|
|
5
4
|
import Button from '@atlaskit/button/standard-button';
|
|
6
5
|
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
7
6
|
import { Box, Flex, xcss } from '@atlaskit/primitives';
|
|
8
7
|
import Spinner from '@atlaskit/spinner';
|
|
9
|
-
import { asyncPopupSelectMessages } from './messages';
|
|
10
8
|
const triggerButtonLabelStyles = xcss({
|
|
11
9
|
textOverflow: 'ellipsis',
|
|
12
10
|
overflow: 'hidden',
|
|
@@ -31,22 +29,23 @@ export const LoadingStateAnimationWrapper = styled.div({
|
|
|
31
29
|
}
|
|
32
30
|
});
|
|
33
31
|
const PopupTrigger = /*#__PURE__*/forwardRef(({
|
|
34
|
-
filterType,
|
|
35
32
|
isSelected,
|
|
36
33
|
isDisabled,
|
|
37
34
|
isLoading,
|
|
38
|
-
selectedOptions
|
|
35
|
+
selectedOptions,
|
|
36
|
+
testId,
|
|
37
|
+
label
|
|
39
38
|
}, ref) => {
|
|
40
39
|
const [firstOption] = selectedOptions || [];
|
|
41
40
|
const hasOptions = selectedOptions && selectedOptions.length > 0;
|
|
42
41
|
const showButtonLoading = !isDisabled && isLoading;
|
|
43
|
-
const
|
|
42
|
+
const tiggerButtonTestId = `${testId}-trigger`;
|
|
44
43
|
const LoadingButton = useCallback(() => /*#__PURE__*/React.createElement(LoadingStateAnimationWrapper, null, /*#__PURE__*/React.createElement(Button, {
|
|
45
44
|
iconAfter: /*#__PURE__*/React.createElement(Spinner, {
|
|
46
45
|
size: 'xsmall'
|
|
47
46
|
}),
|
|
48
|
-
testId: `${
|
|
49
|
-
},
|
|
47
|
+
testId: `${tiggerButtonTestId}--loading-button`
|
|
48
|
+
}, label)), [label, tiggerButtonTestId]);
|
|
50
49
|
const DefaultButton = useCallback(() => /*#__PURE__*/React.createElement(Button, {
|
|
51
50
|
appearance: "default",
|
|
52
51
|
isSelected: isSelected || hasOptions,
|
|
@@ -54,15 +53,15 @@ const PopupTrigger = /*#__PURE__*/forwardRef(({
|
|
|
54
53
|
iconAfter: /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
55
54
|
label: ""
|
|
56
55
|
}),
|
|
57
|
-
testId: `${
|
|
56
|
+
testId: `${tiggerButtonTestId}--button`
|
|
58
57
|
}, /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Box, {
|
|
59
58
|
xcss: triggerButtonLabelStyles
|
|
60
|
-
},
|
|
59
|
+
}, label, firstOption && /*#__PURE__*/React.createElement(React.Fragment, null, ": ", firstOption.label)), selectedOptions && selectedOptions.length > 1 && /*#__PURE__*/React.createElement(Flex, {
|
|
61
60
|
xcss: badgeStyles,
|
|
62
61
|
alignItems: "center"
|
|
63
62
|
}, /*#__PURE__*/React.createElement(Badge, {
|
|
64
63
|
appearance: "primary"
|
|
65
|
-
}, "+", selectedOptions.length - 1)))), [
|
|
64
|
+
}, "+", selectedOptions.length - 1)))), [firstOption, hasOptions, isDisabled, isSelected, label, selectedOptions, tiggerButtonTestId]);
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
67
|
* We had an issue with the popup component referencing a stale DOM ref for the trigger button.
|
|
@@ -70,7 +69,7 @@ const PopupTrigger = /*#__PURE__*/forwardRef(({
|
|
|
70
69
|
*/
|
|
71
70
|
return /*#__PURE__*/React.createElement(Box, {
|
|
72
71
|
ref: ref,
|
|
73
|
-
testId:
|
|
72
|
+
testId: tiggerButtonTestId
|
|
74
73
|
}, showButtonLoading ? /*#__PURE__*/React.createElement(LoadingButton, null) : /*#__PURE__*/React.createElement(DefaultButton, null));
|
|
75
74
|
});
|
|
76
75
|
export default PopupTrigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Flex, xcss } from '@atlaskit/primitives';
|
|
3
|
+
const basicFilterContainerStyles = xcss({
|
|
4
|
+
paddingLeft: 'space.100'
|
|
5
|
+
});
|
|
6
|
+
const BasicFilterContainer = ({}) => {
|
|
7
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
8
|
+
xcss: basicFilterContainerStyles,
|
|
9
|
+
gap: "space.100",
|
|
10
|
+
testId: "clol-basic-filter-container"
|
|
11
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
12
|
+
};
|
|
13
|
+
export default BasicFilterContainer;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { Flex, xcss } from '@atlaskit/primitives';
|
|
2
4
|
import { BasicSearchInput } from '../../common/modal/basic-search-input';
|
|
5
|
+
import BasicFilters from '../basic-filters';
|
|
3
6
|
import { searchMessages } from './messages';
|
|
7
|
+
const basicSearchInputContainerStyles = xcss({
|
|
8
|
+
flexGrow: 1
|
|
9
|
+
});
|
|
4
10
|
const ConfluenceSearchContainer = ({
|
|
5
11
|
cloudId,
|
|
6
12
|
initialSearchValue,
|
|
@@ -22,14 +28,23 @@ const ConfluenceSearchContainer = ({
|
|
|
22
28
|
currentCloudId.current = cloudId;
|
|
23
29
|
}
|
|
24
30
|
}, [cloudId]);
|
|
25
|
-
|
|
31
|
+
const showBasicFilters = useMemo(() => {
|
|
32
|
+
if (getBooleanFF('platform.linking-platform.datasource.show-clol-basic-filters')) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}, []);
|
|
37
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
xcss: basicSearchInputContainerStyles
|
|
40
|
+
}, /*#__PURE__*/React.createElement(BasicSearchInput, {
|
|
26
41
|
testId: "confluence-search-datasource-modal",
|
|
27
42
|
isSearching: isSearching,
|
|
28
43
|
onChange: handleSearchChange,
|
|
29
44
|
onSearch: onSearch,
|
|
30
45
|
searchTerm: searchBarSearchString,
|
|
31
46
|
placeholder: searchMessages.searchLabel,
|
|
32
|
-
fullWidth:
|
|
33
|
-
});
|
|
47
|
+
fullWidth: !showBasicFilters
|
|
48
|
+
}), showBasicFilters && /*#__PURE__*/React.createElement(BasicFilters, null));
|
|
34
49
|
};
|
|
35
50
|
export default ConfluenceSearchContainer;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
2
|
import isEqual from 'lodash/isEqual';
|
|
4
3
|
import { useIntl } from 'react-intl-next';
|
|
5
4
|
import { useDebouncedCallback } from 'use-debounce';
|
|
6
|
-
import {
|
|
7
|
-
import { useDatasourceAnalyticsEvents } from '../../../../../analytics';
|
|
5
|
+
import { FilterPopupSelect } from '../../../../common/modal/popup-select';
|
|
8
6
|
import { useFilterOptions } from '../../hooks/useFilterOptions';
|
|
9
|
-
import CustomMenuList from '../menu-list';
|
|
10
|
-
import CustomControl from './control';
|
|
11
|
-
import CustomDropdownIndicator from './dropdownIndicator';
|
|
12
|
-
import PopupFooter from './footer';
|
|
13
|
-
import formatOptionLabel from './formatOptionLabel';
|
|
14
7
|
import { asyncPopupSelectMessages } from './messages';
|
|
15
|
-
import PopupTrigger from './trigger';
|
|
16
|
-
// Needed to disable filtering from react-select
|
|
17
|
-
const noFilterOptions = () => true;
|
|
18
8
|
export const SEARCH_DEBOUNCE_MS = 350;
|
|
19
9
|
const AsyncPopupSelect = ({
|
|
20
10
|
filterType,
|
|
@@ -27,18 +17,12 @@ const AsyncPopupSelect = ({
|
|
|
27
17
|
const {
|
|
28
18
|
formatMessage
|
|
29
19
|
} = useIntl();
|
|
30
|
-
const {
|
|
31
|
-
fireEvent
|
|
32
|
-
} = useDatasourceAnalyticsEvents();
|
|
33
20
|
const [searchTerm, setSearchTerm] = useState('');
|
|
34
21
|
const [selectedOptions, setSelectedOptions] = useState(selection);
|
|
35
|
-
const [sortedOptions, setSortedOptions] = useState([]);
|
|
36
22
|
const {
|
|
37
23
|
cloudId
|
|
38
24
|
} = site || {};
|
|
39
25
|
const currentSiteCloudId = useRef(cloudId || '');
|
|
40
|
-
const sortPaginatedResults = useRef(false); // this is to track pagination for sorting purpose
|
|
41
|
-
|
|
42
26
|
const {
|
|
43
27
|
filterOptions,
|
|
44
28
|
fetchFilterOptions,
|
|
@@ -56,103 +40,32 @@ const AsyncPopupSelect = ({
|
|
|
56
40
|
searchString
|
|
57
41
|
});
|
|
58
42
|
}, SEARCH_DEBOUNCE_MS);
|
|
59
|
-
const handleInputChange = useCallback(async
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}, [handleDebouncedFetchFilterOptions, searchTerm]);
|
|
43
|
+
const handleInputChange = useCallback(async newSearchTerm => {
|
|
44
|
+
setSearchTerm(newSearchTerm);
|
|
45
|
+
handleDebouncedFetchFilterOptions(newSearchTerm);
|
|
46
|
+
}, [handleDebouncedFetchFilterOptions]);
|
|
65
47
|
const handleOptionSelection = useCallback(newValue => {
|
|
66
48
|
onSelectionChange(filterType, newValue);
|
|
67
49
|
}, [filterType, onSelectionChange]);
|
|
68
|
-
const sortOptionsOnPopupOpen = useCallback(() => {
|
|
69
|
-
if (selectedOptions.length === 0) {
|
|
70
|
-
return setSortedOptions(filterOptions);
|
|
71
|
-
}
|
|
72
|
-
const nonSelectedOptions = filterOptions.filter(option => !selectedOptions.find(selectedOption => selectedOption.value === option.value));
|
|
73
|
-
const newOptions = [...selectedOptions, ...nonSelectedOptions];
|
|
74
|
-
if (!isEqual(newOptions, sortedOptions)) {
|
|
75
|
-
setSortedOptions(newOptions);
|
|
76
|
-
}
|
|
77
|
-
}, [selectedOptions, filterOptions, sortedOptions]);
|
|
78
|
-
const sortOptionsOnResolve = useCallback(() => {
|
|
79
|
-
// when the user is searching, we want the search result to be displayed as it is, and the select component will take care of marking the selected items
|
|
80
|
-
if (searchTerm) {
|
|
81
|
-
sortPaginatedResults.current = false; // set to false to indicate pagination resolve action is completed from the sorting perspective
|
|
82
|
-
return setSortedOptions(filterOptions);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// sortedOptions is empty initially, this will take care of setting the initial value and bring the selected items to the top
|
|
86
|
-
if (sortedOptions.length === 0) {
|
|
87
|
-
return sortOptionsOnPopupOpen();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// this block handles the pagination, where on pagination, we will just append newOptions to the current list
|
|
91
|
-
if (sortPaginatedResults.current) {
|
|
92
|
-
const newOptions = filterOptions.filter(option => !sortedOptions.find(sortedOption => sortedOption.value === option.value));
|
|
93
|
-
if (newOptions.length > 0) {
|
|
94
|
-
setSortedOptions([...sortedOptions, ...newOptions]);
|
|
95
|
-
}
|
|
96
|
-
sortPaginatedResults.current = false; // set to false to indicate pagination resolve action is completed from the sorting perspective
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
sortPaginatedResults.current = false; // set to false to indicate pagination resolve action is completed from the sorting perspective
|
|
100
|
-
sortOptionsOnPopupOpen();
|
|
101
|
-
}, [filterOptions, searchTerm, sortOptionsOnPopupOpen, sortedOptions]);
|
|
102
50
|
const handleShowMore = useCallback(() => {
|
|
103
51
|
if (pageCursor) {
|
|
104
|
-
sortPaginatedResults.current = true;
|
|
105
52
|
fetchFilterOptions({
|
|
106
53
|
pageCursor,
|
|
107
54
|
searchString: searchTerm
|
|
108
55
|
});
|
|
109
|
-
fireEvent('ui.button.clicked.basicSearchDropdown', {
|
|
110
|
-
filterType,
|
|
111
|
-
type: 'showMore'
|
|
112
|
-
});
|
|
113
56
|
}
|
|
114
|
-
}, [fetchFilterOptions,
|
|
57
|
+
}, [fetchFilterOptions, pageCursor, searchTerm]);
|
|
115
58
|
const handleMenuOpen = useCallback(() => {
|
|
116
59
|
if (status === 'empty' || status === 'rejected') {
|
|
117
60
|
// if user searches and gets status as rejected, we want the dropdown to try load the request with searchString when the user reopens the dropdown
|
|
118
61
|
fetchFilterOptions({
|
|
119
62
|
searchString: searchTerm
|
|
120
63
|
});
|
|
121
|
-
} else if (status === 'resolved') {
|
|
122
|
-
sortOptionsOnPopupOpen();
|
|
123
64
|
}
|
|
124
|
-
|
|
125
|
-
filterType,
|
|
126
|
-
selectionCount: selectedOptions.length
|
|
127
|
-
});
|
|
128
|
-
}, [fetchFilterOptions, filterType, fireEvent, searchTerm, selectedOptions.length, sortOptionsOnPopupOpen, status]);
|
|
129
|
-
const handleMenuClose = useCallback(() => {
|
|
130
|
-
/**
|
|
131
|
-
* Clearing the search is to ensure that the sortOptionsOnPopupOpen logic does not mess up.
|
|
132
|
-
* Without this, when the user opens, sortOptionsOnPopupOpen will inject the selected options to the list and the list count and values will be off
|
|
133
|
-
*/
|
|
134
|
-
if (searchTerm) {
|
|
135
|
-
handleInputChange('', {
|
|
136
|
-
action: 'input-change',
|
|
137
|
-
prevInputValue: searchTerm
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
fireEvent('ui.dropdown.closed.basicSearchDropdown', {
|
|
141
|
-
filterType,
|
|
142
|
-
selectionCount: selectedOptions.length
|
|
143
|
-
});
|
|
144
|
-
}, [filterType, fireEvent, handleInputChange, searchTerm, selectedOptions.length]);
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
if (status === 'resolved') {
|
|
147
|
-
sortOptionsOnResolve();
|
|
148
|
-
}
|
|
149
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
150
|
-
}, [status]); // we only want the sortOptionsOnResolve to run when there is a status change
|
|
151
|
-
|
|
65
|
+
}, [fetchFilterOptions, searchTerm, status]);
|
|
152
66
|
useEffect(() => {
|
|
153
67
|
if (cloudId && currentSiteCloudId.current !== cloudId) {
|
|
154
68
|
currentSiteCloudId.current = cloudId;
|
|
155
|
-
setSortedOptions([]);
|
|
156
69
|
setSearchTerm('');
|
|
157
70
|
resetHook();
|
|
158
71
|
}
|
|
@@ -167,29 +80,27 @@ const AsyncPopupSelect = ({
|
|
|
167
80
|
const isLoading = status === 'loading' || status === 'empty';
|
|
168
81
|
const isLoadingMore = status === 'loadingMore';
|
|
169
82
|
const isEmpty = status === 'resolved' && filterOptionsLength === 0;
|
|
170
|
-
const popupSelectOptions = isLoading || isError ? [] :
|
|
83
|
+
const popupSelectOptions = isLoading || isError ? [] : filterOptions; // if not set to [], then on loading, no loading UI will be shown
|
|
171
84
|
const areAllResultsLoaded = filterOptionsLength === totalCount;
|
|
172
85
|
const shouldShowFooter = (status === 'resolved' || isLoadingMore) && filterOptionsLength > 0; // footer should not disappear when there is an inline spinner for loading more data
|
|
173
86
|
const shouldDisplayShowMoreButton = status === 'resolved' && !!pageCursor && !areAllResultsLoaded;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
isLoading: isLoading,
|
|
190
|
-
placeholder: formatMessage(asyncPopupSelectMessages.selectPlaceholder),
|
|
87
|
+
const triggerButtonLabel = formatMessage(asyncPopupSelectMessages[`${filterType}Label`]);
|
|
88
|
+
return /*#__PURE__*/React.createElement(FilterPopupSelect, {
|
|
89
|
+
filterName: `jlol-basic-filter-${filterType}`,
|
|
90
|
+
status: status,
|
|
91
|
+
showLoading: isLoading,
|
|
92
|
+
showHydrating: isJQLHydrating,
|
|
93
|
+
isDisabled: isDisabled,
|
|
94
|
+
totalCount: totalCount,
|
|
95
|
+
shouldShowFooter: shouldShowFooter,
|
|
96
|
+
selectedOptions: selectedOptions,
|
|
97
|
+
options: popupSelectOptions,
|
|
98
|
+
buttonLabel: triggerButtonLabel,
|
|
99
|
+
onInputChange: handleInputChange,
|
|
100
|
+
onSelectionChange: handleOptionSelection,
|
|
101
|
+
onMenuOpen: handleMenuOpen,
|
|
191
102
|
menuListProps: {
|
|
192
|
-
filterType,
|
|
103
|
+
filterName: filterType,
|
|
193
104
|
isError,
|
|
194
105
|
isEmpty,
|
|
195
106
|
isLoading,
|
|
@@ -197,38 +108,7 @@ const AsyncPopupSelect = ({
|
|
|
197
108
|
handleShowMore,
|
|
198
109
|
errors,
|
|
199
110
|
showMore: shouldDisplayShowMoreButton
|
|
200
|
-
}
|
|
201
|
-
components: {
|
|
202
|
-
Option: CheckboxOption,
|
|
203
|
-
Control: CustomControl,
|
|
204
|
-
MenuList: CustomMenuList,
|
|
205
|
-
DropdownIndicator: CustomDropdownIndicator,
|
|
206
|
-
LoadingIndicator: undefined,
|
|
207
|
-
// disables the three ... indicator in the searchbox when picker is loading
|
|
208
|
-
IndicatorSeparator: undefined // disables the | separator between search input and icon
|
|
209
|
-
},
|
|
210
|
-
options: popupSelectOptions,
|
|
211
|
-
value: selectedOptions,
|
|
212
|
-
filterOption: noFilterOptions,
|
|
213
|
-
formatOptionLabel: formatOptionLabel,
|
|
214
|
-
onChange: handleOptionSelection,
|
|
215
|
-
onInputChange: handleInputChange,
|
|
216
|
-
onOpen: handleMenuOpen,
|
|
217
|
-
onClose: handleMenuClose,
|
|
218
|
-
target: ({
|
|
219
|
-
isOpen,
|
|
220
|
-
...triggerProps
|
|
221
|
-
}) => /*#__PURE__*/React.createElement(PopupTrigger, _extends({}, triggerProps, {
|
|
222
|
-
filterType: filterType,
|
|
223
|
-
selectedOptions: selectedOptions,
|
|
224
|
-
isSelected: isOpen,
|
|
225
|
-
isDisabled: isDisabled,
|
|
226
|
-
isLoading: isJQLHydrating
|
|
227
|
-
})),
|
|
228
|
-
footer: shouldShowFooter && /*#__PURE__*/React.createElement(PopupFooter, {
|
|
229
|
-
currentDisplayCount: popupSelectOptions.length,
|
|
230
|
-
totalCount: totalCount
|
|
231
|
-
})
|
|
111
|
+
}
|
|
232
112
|
});
|
|
233
113
|
};
|
|
234
114
|
export default AsyncPopupSelect;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { defineMessages } from 'react-intl-next';
|
|
2
2
|
export const asyncPopupSelectMessages = defineMessages({
|
|
3
|
-
selectPlaceholder: {
|
|
4
|
-
id: 'linkDataSource.basic-filter.dropdown.select.placeholder',
|
|
5
|
-
description: 'Placeholder text to be displayed for the search input box.',
|
|
6
|
-
defaultMessage: 'Search'
|
|
7
|
-
},
|
|
8
|
-
paginationDetails: {
|
|
9
|
-
id: 'linkDataSource.basic-filter.footer.pagination-details',
|
|
10
|
-
description: 'Text to indicate page count and total count information.',
|
|
11
|
-
defaultMessage: '{currentDisplayCount} of {totalCount}'
|
|
12
|
-
},
|
|
13
3
|
projectLabel: {
|
|
14
4
|
id: 'linkDataSource.basic-filter.project.label',
|
|
15
5
|
description: 'Label to be displayed for project filter dropdown button.',
|
|
@@ -29,10 +19,5 @@ export const asyncPopupSelectMessages = defineMessages({
|
|
|
29
19
|
id: 'linkDataSource.basic-filter.assignee.label',
|
|
30
20
|
description: 'Label to be displayed for assignee filter dropdown button.',
|
|
31
21
|
defaultMessage: 'Assignee'
|
|
32
|
-
},
|
|
33
|
-
showMoreMessage: {
|
|
34
|
-
id: 'linkDataSource.basic-filter.showMoreButton',
|
|
35
|
-
defaultMessage: 'Show more',
|
|
36
|
-
description: 'The text to show more options in dropdown'
|
|
37
22
|
}
|
|
38
23
|
});
|
|
@@ -193,7 +193,8 @@ export const JiraSearchContainer = props => {
|
|
|
193
193
|
onSearch: handleSearch,
|
|
194
194
|
searchTerm: basicSearchTerm,
|
|
195
195
|
placeholder: basicSearchInputMessages.basicTextSearchLabel,
|
|
196
|
-
testId: "jira-datasource-modal"
|
|
196
|
+
testId: "jira-datasource-modal",
|
|
197
|
+
fullWidth: !showBasicFilters
|
|
197
198
|
}), showBasicFilters && jsx(BasicFilters, {
|
|
198
199
|
jql: searchBarJql,
|
|
199
200
|
site: site,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { useIntl } from 'react-intl-next';
|
|
5
5
|
import { LoadingButton } from '@atlaskit/button';
|
|
6
6
|
import SearchIcon from '@atlaskit/icon/glyph/editor/search';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import Textfield from '@atlaskit/textfield';
|
|
9
8
|
import { useDatasourceAnalyticsEvents } from '../../../../analytics';
|
|
10
9
|
import { basicSearchInputMessages } from './messages';
|
|
@@ -39,15 +38,8 @@ export var BasicSearchInput = function BasicSearchInput(_ref) {
|
|
|
39
38
|
e.preventDefault();
|
|
40
39
|
handleSearchWithAnalytics();
|
|
41
40
|
};
|
|
42
|
-
var showBasicFilters = useMemo(function () {
|
|
43
|
-
if (getBooleanFF('platform.linking-platform.datasource.show-jlol-basic-filters')) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}, []);
|
|
48
|
-
var isFullWidth = fullWidth || !showBasicFilters;
|
|
49
41
|
return jsx("form", {
|
|
50
|
-
css:
|
|
42
|
+
css: fullWidth ? formStyles : formWithMaxWidthStyles,
|
|
51
43
|
onSubmit: handleFormSubmit
|
|
52
44
|
}, jsx(Textfield, {
|
|
53
45
|
elemAfterInput: jsx(LoadingButton, {
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
6
|
+
var _excluded = ["isOpen"];
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import isEqual from 'lodash/isEqual';
|
|
10
|
+
import { useIntl } from 'react-intl-next';
|
|
11
|
+
import { CheckboxOption, PopupSelect } from '@atlaskit/select';
|
|
12
|
+
import { useDatasourceAnalyticsEvents } from '../../../../analytics';
|
|
13
|
+
import CustomControl from './control';
|
|
14
|
+
import CustomDropdownIndicator from './dropdownIndicator';
|
|
15
|
+
import PopupFooter from './footer';
|
|
16
|
+
import formatOptionLabel from './formatOptionLabel';
|
|
17
|
+
import CustomMenuList from './menu-list';
|
|
18
|
+
import { asyncPopupSelectMessages } from './messages';
|
|
19
|
+
import PopupTrigger from './trigger';
|
|
20
|
+
// Needed to disable filtering from react-select
|
|
21
|
+
var noFilterOptions = function noFilterOptions() {
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
export var FilterPopupSelect = function FilterPopupSelect(_ref) {
|
|
25
|
+
var filterName = _ref.filterName,
|
|
26
|
+
totalCount = _ref.totalCount,
|
|
27
|
+
status = _ref.status,
|
|
28
|
+
buttonLabel = _ref.buttonLabel,
|
|
29
|
+
_ref$showLoading = _ref.showLoading,
|
|
30
|
+
showLoading = _ref$showLoading === void 0 ? false : _ref$showLoading,
|
|
31
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
32
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
33
|
+
_ref$showHydrating = _ref.showHydrating,
|
|
34
|
+
showHydrating = _ref$showHydrating === void 0 ? false : _ref$showHydrating,
|
|
35
|
+
_ref$shouldShowFooter = _ref.shouldShowFooter,
|
|
36
|
+
shouldShowFooter = _ref$shouldShowFooter === void 0 ? true : _ref$shouldShowFooter,
|
|
37
|
+
menuListProps = _ref.menuListProps,
|
|
38
|
+
options = _ref.options,
|
|
39
|
+
selectedOptions = _ref.selectedOptions,
|
|
40
|
+
onSelectionChange = _ref.onSelectionChange,
|
|
41
|
+
onInputChange = _ref.onInputChange,
|
|
42
|
+
onMenuClose = _ref.onMenuClose,
|
|
43
|
+
onMenuOpen = _ref.onMenuOpen;
|
|
44
|
+
var _useIntl = useIntl(),
|
|
45
|
+
formatMessage = _useIntl.formatMessage;
|
|
46
|
+
var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
|
|
47
|
+
fireEvent = _useDatasourceAnalyti.fireEvent;
|
|
48
|
+
var _useState = useState(''),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
searchTerm = _useState2[0],
|
|
51
|
+
setSearchTerm = _useState2[1];
|
|
52
|
+
var _useState3 = useState([]),
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
sortedOptions = _useState4[0],
|
|
55
|
+
setSortedOptions = _useState4[1];
|
|
56
|
+
var sortPaginatedResults = useRef(false); // this is to track pagination for sorting purpose
|
|
57
|
+
|
|
58
|
+
var sortOptionsOnPopupOpen = useCallback(function () {
|
|
59
|
+
if (selectedOptions.length === 0) {
|
|
60
|
+
return setSortedOptions(options);
|
|
61
|
+
}
|
|
62
|
+
var nonSelectedOptions = options.filter(function (option) {
|
|
63
|
+
return !selectedOptions.find(function (selectedOption) {
|
|
64
|
+
return selectedOption.value === option.value;
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
var newOptions = [].concat(_toConsumableArray(selectedOptions), _toConsumableArray(nonSelectedOptions));
|
|
68
|
+
if (!isEqual(newOptions, sortedOptions)) {
|
|
69
|
+
setSortedOptions(newOptions);
|
|
70
|
+
}
|
|
71
|
+
}, [selectedOptions, options, sortedOptions]);
|
|
72
|
+
var sortOptionsOnResolve = useCallback(function () {
|
|
73
|
+
// when the user is searching, we want the search result to be displayed as it is, and the select component will take care of marking the selected items
|
|
74
|
+
if (searchTerm) {
|
|
75
|
+
sortPaginatedResults.current = false; // set to false to indicate pagination resolve action is completed from the sorting perspective
|
|
76
|
+
return setSortedOptions(options);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// sortedOptions is empty initially, this will take care of setting the initial value and bring the selected items to the top
|
|
80
|
+
if (sortedOptions.length === 0) {
|
|
81
|
+
return sortOptionsOnPopupOpen();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// this block handles the pagination, where on pagination, we will just append newOptions to the current list
|
|
85
|
+
if (sortPaginatedResults.current) {
|
|
86
|
+
var newOptions = options.filter(function (option) {
|
|
87
|
+
return !sortedOptions.find(function (sortedOption) {
|
|
88
|
+
return sortedOption.value === option.value;
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
if (newOptions.length > 0) {
|
|
92
|
+
setSortedOptions([].concat(_toConsumableArray(sortedOptions), _toConsumableArray(newOptions)));
|
|
93
|
+
}
|
|
94
|
+
sortPaginatedResults.current = false; // set to false to indicate pagination resolve action is completed from the sorting perspective
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
sortPaginatedResults.current = false; // set to false to indicate pagination resolve action is completed from the sorting perspective
|
|
98
|
+
sortOptionsOnPopupOpen();
|
|
99
|
+
}, [options, searchTerm, sortOptionsOnPopupOpen, sortedOptions]);
|
|
100
|
+
var handleMenuOpen = useCallback(function () {
|
|
101
|
+
if (status === 'resolved') {
|
|
102
|
+
sortOptionsOnPopupOpen();
|
|
103
|
+
}
|
|
104
|
+
fireEvent('ui.dropdown.opened.basicSearchDropdown', {
|
|
105
|
+
filterName: filterName,
|
|
106
|
+
selectionCount: selectedOptions.length
|
|
107
|
+
});
|
|
108
|
+
onMenuOpen === null || onMenuOpen === void 0 || onMenuOpen();
|
|
109
|
+
}, [filterName, fireEvent, onMenuOpen, selectedOptions.length, sortOptionsOnPopupOpen, status]);
|
|
110
|
+
var handleMenuClose = useCallback(function () {
|
|
111
|
+
/**
|
|
112
|
+
* Clearing the search is to ensure that the sortOptionsOnPopupOpen logic does not mess up.
|
|
113
|
+
* Without this, when the user opens, sortOptionsOnPopupOpen will inject the selected options to the list and the list count and values will be off
|
|
114
|
+
*/
|
|
115
|
+
if (searchTerm) {
|
|
116
|
+
setSearchTerm('');
|
|
117
|
+
}
|
|
118
|
+
onMenuClose === null || onMenuClose === void 0 || onMenuClose();
|
|
119
|
+
fireEvent('ui.dropdown.closed.basicSearchDropdown', {
|
|
120
|
+
filterName: filterName,
|
|
121
|
+
selectionCount: selectedOptions.length
|
|
122
|
+
});
|
|
123
|
+
}, [filterName, fireEvent, onMenuClose, searchTerm, selectedOptions.length]);
|
|
124
|
+
var handleInputChange = useCallback( /*#__PURE__*/function () {
|
|
125
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(newSearchTerm, actionMeta) {
|
|
126
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
127
|
+
while (1) switch (_context.prev = _context.next) {
|
|
128
|
+
case 0:
|
|
129
|
+
if (actionMeta.action === 'input-change' && newSearchTerm !== searchTerm) {
|
|
130
|
+
setSearchTerm(newSearchTerm);
|
|
131
|
+
onInputChange(newSearchTerm, actionMeta);
|
|
132
|
+
}
|
|
133
|
+
case 1:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context.stop();
|
|
136
|
+
}
|
|
137
|
+
}, _callee);
|
|
138
|
+
}));
|
|
139
|
+
return function (_x, _x2) {
|
|
140
|
+
return _ref2.apply(this, arguments);
|
|
141
|
+
};
|
|
142
|
+
}(), [onInputChange, searchTerm]);
|
|
143
|
+
useEffect(function () {
|
|
144
|
+
if (status === 'resolved') {
|
|
145
|
+
sortOptionsOnResolve();
|
|
146
|
+
}
|
|
147
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
148
|
+
}, [status]); // we only want the sortOptionsOnResolve to run when there is a status change
|
|
149
|
+
|
|
150
|
+
useEffect(function () {
|
|
151
|
+
if (status === 'loadingMore') {
|
|
152
|
+
sortPaginatedResults.current = true;
|
|
153
|
+
}
|
|
154
|
+
}, [status]);
|
|
155
|
+
return /*#__PURE__*/React.createElement(PopupSelect, {
|
|
156
|
+
isMulti: true,
|
|
157
|
+
maxMenuWidth: 300,
|
|
158
|
+
minMenuWidth: 300,
|
|
159
|
+
testId: "".concat(filterName, "-popup-select"),
|
|
160
|
+
inputId: "".concat(filterName, "-popup-select--input")
|
|
161
|
+
/*
|
|
162
|
+
this threshold controls the display of the search control (input field for search)
|
|
163
|
+
if this threshold is less than 0, when typing a search string that returns no results it will not remove the search control
|
|
164
|
+
if this threshold is 0 or higher, it will remove the search control when there are no results, the user will be unable to clear the search to see more results
|
|
165
|
+
*/,
|
|
166
|
+
searchThreshold: -1,
|
|
167
|
+
inputValue: searchTerm,
|
|
168
|
+
closeMenuOnSelect: false,
|
|
169
|
+
hideSelectedOptions: false,
|
|
170
|
+
isLoading: showLoading,
|
|
171
|
+
placeholder: formatMessage(asyncPopupSelectMessages.selectPlaceholder),
|
|
172
|
+
menuListProps: menuListProps,
|
|
173
|
+
components: {
|
|
174
|
+
Option: CheckboxOption,
|
|
175
|
+
Control: CustomControl,
|
|
176
|
+
MenuList: CustomMenuList,
|
|
177
|
+
DropdownIndicator: CustomDropdownIndicator,
|
|
178
|
+
LoadingIndicator: undefined,
|
|
179
|
+
// disables the three ... indicator in the searchbox when picker is loading
|
|
180
|
+
IndicatorSeparator: undefined // disables the | separator between search input and icon
|
|
181
|
+
},
|
|
182
|
+
options: sortedOptions,
|
|
183
|
+
value: selectedOptions,
|
|
184
|
+
filterOption: noFilterOptions,
|
|
185
|
+
formatOptionLabel: formatOptionLabel,
|
|
186
|
+
onChange: onSelectionChange,
|
|
187
|
+
onInputChange: handleInputChange,
|
|
188
|
+
onOpen: handleMenuOpen,
|
|
189
|
+
onClose: handleMenuClose,
|
|
190
|
+
target: function target(_ref3) {
|
|
191
|
+
var isOpen = _ref3.isOpen,
|
|
192
|
+
triggerProps = _objectWithoutProperties(_ref3, _excluded);
|
|
193
|
+
return /*#__PURE__*/React.createElement(PopupTrigger, _extends({}, triggerProps, {
|
|
194
|
+
label: buttonLabel,
|
|
195
|
+
selectedOptions: selectedOptions,
|
|
196
|
+
isSelected: isOpen,
|
|
197
|
+
isDisabled: isDisabled,
|
|
198
|
+
isLoading: showHydrating,
|
|
199
|
+
testId: filterName
|
|
200
|
+
}));
|
|
201
|
+
},
|
|
202
|
+
footer: shouldShowFooter && /*#__PURE__*/React.createElement(PopupFooter, {
|
|
203
|
+
currentDisplayCount: options.length,
|
|
204
|
+
totalCount: totalCount
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
};
|