@rh-support/components 2.5.2 → 2.5.4

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.
Files changed (60) hide show
  1. package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts +12 -7
  2. package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
  3. package/lib/esm/Functional/CaseContactsSelectorExternal.js +67 -60
  4. package/lib/esm/OwnerTypeaheadDropdown/OwnerTypeaheadDropdown.d.ts +3 -1
  5. package/lib/esm/OwnerTypeaheadDropdown/OwnerTypeaheadDropdown.d.ts.map +1 -1
  6. package/lib/esm/OwnerTypeaheadDropdown/OwnerTypeaheadDropdown.js +53 -6
  7. package/lib/esm/SingleSelectDropdown/SingleSelectDropdown.d.ts +27 -0
  8. package/lib/esm/SingleSelectDropdown/SingleSelectDropdown.d.ts.map +1 -0
  9. package/lib/esm/SingleSelectDropdown/SingleSelectDropdown.js +26 -0
  10. package/lib/esm/SingleSelectDropdown/index.d.ts +2 -0
  11. package/lib/esm/SingleSelectDropdown/index.d.ts.map +1 -0
  12. package/lib/esm/SingleSelectDropdown/index.js +1 -0
  13. package/lib/esm/TypeaheadDropdown/TypeaheadDropdown.d.ts +13 -1
  14. package/lib/esm/TypeaheadDropdown/TypeaheadDropdown.d.ts.map +1 -1
  15. package/lib/esm/TypeaheadDropdown/TypeaheadDropdown.js +99 -24
  16. package/lib/esm/hooks/index.d.ts +1 -0
  17. package/lib/esm/hooks/index.d.ts.map +1 -1
  18. package/lib/esm/hooks/index.js +1 -0
  19. package/lib/esm/hooks/usePatternFlySingleSelectToggle.d.ts +16 -0
  20. package/lib/esm/hooks/usePatternFlySingleSelectToggle.d.ts.map +1 -0
  21. package/lib/esm/hooks/usePatternFlySingleSelectToggle.js +17 -0
  22. package/lib/esm/index.d.ts +1 -1
  23. package/lib/esm/index.d.ts.map +1 -1
  24. package/lib/esm/index.js +1 -1
  25. package/package.json +8 -10
  26. package/lib/esm/DropDownList/AsyncDropDownList.d.ts +0 -6
  27. package/lib/esm/DropDownList/AsyncDropDownList.d.ts.map +0 -1
  28. package/lib/esm/DropDownList/AsyncDropDownList.js +0 -6
  29. package/lib/esm/DropDownList/DropDownList.d.ts +0 -9
  30. package/lib/esm/DropDownList/DropDownList.d.ts.map +0 -1
  31. package/lib/esm/DropDownList/DropDownList.js +0 -116
  32. package/lib/esm/DropDownList/DropdownWrapper.d.ts +0 -16
  33. package/lib/esm/DropDownList/DropdownWrapper.d.ts.map +0 -1
  34. package/lib/esm/DropDownList/DropdownWrapper.js +0 -19
  35. package/lib/esm/DropDownList/MultiSelectDropdownList.d.ts +0 -4
  36. package/lib/esm/DropDownList/MultiSelectDropdownList.d.ts.map +0 -1
  37. package/lib/esm/DropDownList/MultiSelectDropdownList.js +0 -4
  38. package/lib/esm/DropDownList/Readme.md +0 -114
  39. package/lib/esm/DropDownList/SearchableList.d.ts +0 -14
  40. package/lib/esm/DropDownList/SearchableList.d.ts.map +0 -1
  41. package/lib/esm/DropDownList/SearchableList.js +0 -98
  42. package/lib/esm/DropDownList/SelectList.d.ts +0 -11
  43. package/lib/esm/DropDownList/SelectList.d.ts.map +0 -1
  44. package/lib/esm/DropDownList/SelectList.js +0 -35
  45. package/lib/esm/DropDownList/async.d.ts +0 -9
  46. package/lib/esm/DropDownList/async.d.ts.map +0 -1
  47. package/lib/esm/DropDownList/async.js +0 -111
  48. package/lib/esm/DropDownList/dropdownList.css +0 -59
  49. package/lib/esm/DropDownList/dropdownUtils.d.ts +0 -5
  50. package/lib/esm/DropDownList/dropdownUtils.d.ts.map +0 -1
  51. package/lib/esm/DropDownList/dropdownUtils.js +0 -23
  52. package/lib/esm/DropDownList/index.d.ts +0 -4
  53. package/lib/esm/DropDownList/index.d.ts.map +0 -1
  54. package/lib/esm/DropDownList/index.js +0 -3
  55. package/lib/esm/DropDownList/types.d.ts +0 -53
  56. package/lib/esm/DropDownList/types.d.ts.map +0 -1
  57. package/lib/esm/DropDownList/types.js +0 -1
  58. package/lib/esm/DropDownList/withMulti.d.ts +0 -5
  59. package/lib/esm/DropDownList/withMulti.d.ts.map +0 -1
  60. package/lib/esm/DropDownList/withMulti.js +0 -46
@@ -1,35 +0,0 @@
1
- import CaretDownIcon from '@patternfly/react-icons/dist/js/icons/caret-down-icon';
2
- import { useSelect } from 'downshift';
3
- import React from 'react';
4
- import { LoadingIndicator } from '../LoadingIndicator/LoadingIndicator';
5
- import { itemToString, multiSelectDropdownStateReducer, noop } from './dropdownUtils';
6
- import DropdownWrapper from './DropdownWrapper';
7
- export default function SelectList(props) {
8
- const onIsOpenChange = (changes) => {
9
- if (!changes.isOpen && changes.type !== useSelect.stateChangeTypes.ItemClick) {
10
- props.onOuterClick && props.onOuterClick(props.selectedItem);
11
- }
12
- };
13
- const downshift = useSelect(Object.assign({ selectedItem: props.selectedItem, items: props.list, onIsOpenChange, onSelectedItemChange: props.onChange, labelId: `${props.id}-label`, itemToString }, (props.multiSelect && { stateReducer: multiSelectDropdownStateReducer })));
14
- const { getToggleButtonProps, getLabelProps, getMenuProps, isOpen } = downshift;
15
- const renderToggleButton = () => {
16
- var _a;
17
- return (React.createElement("button", Object.assign({ type: "button" }, getToggleButtonProps({
18
- id: `pcm-${props.id}-${props.name}-toggle`,
19
- className: `pf-v5-c-select__toggle ${props.isInValid ? 'form-invalid' : ''}`,
20
- disabled: props.disabled || props.isLoadingList,
21
- 'aria-label': `${isOpen ? 'Close ' + props.title : 'Open ' + props.title}${props.selectedItem ? '. The selected option is ' + itemToString(props.selectedItem) + '.' : ''}`,
22
- 'aria-invalid': props.isInValid,
23
- name: props.name,
24
- title: itemToString(props.selectedItem) || props.placeholder,
25
- 'data-tracking-id': (_a = props['data-tracking-id']) !== null && _a !== void 0 ? _a : '',
26
- onClick: props.onMenuToggle ? () => props.onMenuToggle() : noop,
27
- })),
28
- React.createElement("div", { className: "pf-v5-c-select__toggle-wrapper" },
29
- React.createElement("span", { className: "pf-v5-c-select__toggle-text" }, itemToString(props.selectedItem) || (React.createElement("span", { className: "pf-v5-c-select__placeholder-text" }, props.placeholder)))),
30
- React.createElement(LoadingIndicator, { isInline: true, show: props.isLoadingList }),
31
- !props.isLoadingList && (React.createElement("span", { className: "pf-v5-c-select__toggle-arrow" },
32
- React.createElement(CaretDownIcon, null)))));
33
- };
34
- return (React.createElement(DropdownWrapper, { id: props.id, className: props.className, label: props.label, isOpen: isOpen, getMenuProps: getMenuProps, getLabelProps: getLabelProps, toggleMenuComponent: renderToggleButton(), "data-tracking-id": props['data-tracking-id'], hasTwoColumns: props.hasTwoColumns }, isOpen && props.renderListItems(downshift)));
35
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { IAsyncOnlyProps, IDropdownListBasePropsForAsync } from './types';
3
- export declare function useAsync<OptionType, DropdownPropsType extends IDropdownListBasePropsForAsync<OptionType>>(props: DropdownPropsType & IAsyncOnlyProps<OptionType>): DropdownPropsType;
4
- export declare function withAsync<DropdownPropsType extends IDropdownListBasePropsForAsync<OptionType>, OptionType>(WrappedComponent: React.ComponentType<DropdownPropsType>): {
5
- (props: DropdownPropsType & IAsyncOnlyProps<OptionType>): React.JSX.Element;
6
- displayName: string;
7
- defaultProps: {};
8
- };
9
- //# sourceMappingURL=async.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/DropDownList/async.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAiB1E,wBAAgB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,SAAS,8BAA8B,CAAC,UAAU,CAAC,EACrG,KAAK,EAAE,iBAAiB,GAAG,eAAe,CAAC,UAAU,CAAC,GACvD,iBAAiB,CA6HnB;AAED,wBAAgB,SAAS,CAAC,iBAAiB,SAAS,8BAA8B,CAAC,UAAU,CAAC,EAAE,UAAU,EACtG,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC;YAE1B,iBAAiB,GAAG,eAAe,CAAC,UAAU,CAAC;;;EAUhF"}
@@ -1,111 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import debounce from 'lodash/debounce';
13
- import React, { useCallback, useEffect, useRef } from 'react';
14
- import { useForceUpdate, useLRUCache } from '../hooks';
15
- import { usePrevious } from '../hooks/usePrevious';
16
- // Most of the code credit goes to
17
- // https://github.com/ericgio/react-bootstrap-typeahead/blob/master/src/behaviors/async.js
18
- const defaultProps = {
19
- delay: 200,
20
- minLength: 2,
21
- promptText: '',
22
- searchText: 'Searching...',
23
- useCache: false,
24
- };
25
- export function useAsync(props) {
26
- const { delay, isLoadingList, minLength, onInputChange, onSearch, useCache, list, onInputBlur, emptyListLabel, onClearSelection, suggestedItems } = props, otherProps = __rest(props, ["delay", "isLoadingList", "minLength", "onInputChange", "onSearch", "useCache", "list", "onInputBlur", "emptyListLabel", "onClearSelection", "suggestedItems"]);
27
- const { getFromCache, setInCache, clearCache } = useLRUCache(25);
28
- const handleSearchDebouncedRef = useRef();
29
- const queryRef = useRef('');
30
- const forceUpdate = useForceUpdate();
31
- const prevProps = usePrevious(props);
32
- const handleSearch = useCallback((query) => {
33
- queryRef.current = query;
34
- if (!query || (minLength && query.length < minLength)) {
35
- return;
36
- }
37
- // Use cached results, if applicable.
38
- if (useCache && getFromCache(query)) {
39
- // Re-render the component with the cached results.
40
- forceUpdate();
41
- return;
42
- }
43
- // Perform the search.
44
- onSearch(query);
45
- },
46
- // eslint-disable-next-line react-hooks/exhaustive-deps
47
- [forceUpdate, minLength, onSearch, useCache]);
48
- // Set the debounced search function.
49
- useEffect(() => {
50
- handleSearchDebouncedRef.current = debounce(handleSearch, delay);
51
- return () => {
52
- handleSearchDebouncedRef.current && handleSearchDebouncedRef.current.cancel();
53
- };
54
- }, [delay, handleSearch]);
55
- useEffect(() => {
56
- // Ensure that we've gone from a loading to a completed state. Otherwise
57
- // an empty response could get cached if the component updates during the
58
- // request (eg: if the parent re-renders for some reason).
59
- // NOTE: There is a limitation that empty responses will not be cached.
60
- const listToCache = list.filter((item) => !item.isNotSearchable);
61
- if (!isLoadingList && useCache && queryRef.current && (listToCache || []).length > 0) {
62
- setInCache(queryRef.current, list);
63
- }
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
- }, [list, isLoadingList, useCache]);
66
- useEffect(() => {
67
- if (prevProps && prevProps.useCache && !useCache) {
68
- clearCache();
69
- }
70
- return () => {
71
- clearCache();
72
- };
73
- // eslint-disable-next-line react-hooks/exhaustive-deps
74
- }, [useCache]);
75
- const getEmptyLabel = () => {
76
- if (!queryRef.current.length) {
77
- return props.promptText;
78
- }
79
- if (isLoadingList) {
80
- return props.searchText;
81
- }
82
- return emptyListLabel;
83
- };
84
- const handleInputBlur = (e) => {
85
- onInputBlur && onInputBlur(e);
86
- };
87
- const handleClearSelection = () => {
88
- onClearSelection && onClearSelection();
89
- queryRef.current = '';
90
- };
91
- const handleInputChange = useCallback((query) => {
92
- onInputChange && onInputChange(query);
93
- handleSearchDebouncedRef.current && handleSearchDebouncedRef.current(query);
94
- }, [onInputChange]);
95
- const cachedQuery = getFromCache(queryRef.current);
96
- return Object.assign(Object.assign({}, otherProps), { isLoadingList,
97
- minLength, onInputChange: handleInputChange, emptyListLabel: getEmptyLabel(), list: useCache && cachedQuery
98
- ? cachedQuery
99
- : !queryRef.current
100
- ? (suggestedItems || []).length > 0
101
- ? suggestedItems
102
- : list
103
- : list, onInputBlur: handleInputBlur, searchable: true, onClearSelection: handleClearSelection, isAsyncSearch: true });
104
- }
105
- export function withAsync(WrappedComponent) {
106
- const AsyncDropdown = (props) => (React.createElement(WrappedComponent, Object.assign({}, useAsync(props))));
107
- const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
108
- AsyncDropdown.displayName = `withAsync${displayName}`;
109
- AsyncDropdown.defaultProps = defaultProps;
110
- return AsyncDropdown;
111
- }
@@ -1,59 +0,0 @@
1
- .downshift {
2
- position: relative;
3
- }
4
-
5
- .downshift input {
6
- border: none;
7
- padding: 6px;
8
- }
9
-
10
- .downshift > .pf-v5-c-select__toggle.form-invalid {
11
- border-bottom: 2px solid #c9190b;
12
- }
13
-
14
- .downshift > .pf-v5-c-select__toggle.form-invalid[disabled] {
15
- background-color: #ededed;
16
- border-color: #ededed;
17
- }
18
-
19
- .downshift .downshift-menu li[disabled] {
20
- background: #f0f0f0;
21
- cursor: not-allowed;
22
- opacity: 0.3;
23
- }
24
-
25
- .downshift .downshift-menu .downshift-item.highlighted:not(:hover) {
26
- background-color: #ededed;
27
- }
28
-
29
- .downshift .downshift-menu li.dropdown-divider {
30
- height: 0;
31
- padding: 0;
32
- overflow: hidden;
33
- border-top: 1px solid #e9ecef;
34
- }
35
-
36
- .downshift .pf-v5-c-select__placeholder-text {
37
- color: #6a6e73;
38
- }
39
-
40
- .downshift .pf-v5-c-select__menu-wrapper {
41
- display: flex;
42
- }
43
-
44
- .downshift .pf-v5-c-select__menu-wrapper:hover {
45
- background-color: rgb(240, 240, 240);
46
- }
47
-
48
- .downshift .downshift-menu.open {
49
- visibility: visible;
50
- z-index: 89;
51
- }
52
-
53
- .downshift .downshift-menu {
54
- visibility: hidden;
55
- }
56
-
57
- .hide-in-pdf {
58
- display: none !important;
59
- }
@@ -1,5 +0,0 @@
1
- import { IOption } from '@rh-support/types/shared';
2
- export declare function itemToString<T>(item: IOption<T>): string;
3
- export declare const noop: () => void;
4
- export declare const multiSelectDropdownStateReducer: (state: any, actionAndChanges: any) => any;
5
- //# sourceMappingURL=dropdownUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropdownUtils.d.ts","sourceRoot":"","sources":["../../../src/DropDownList/dropdownUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAExD;AAED,eAAO,MAAM,IAAI,YAAW,CAAC;AAE7B,eAAO,MAAM,+BAA+B,4CAoC3C,CAAC"}
@@ -1,23 +0,0 @@
1
- import { useCombobox, useSelect } from 'downshift';
2
- export function itemToString(item) {
3
- return item ? item.label : '';
4
- }
5
- export const noop = () => { };
6
- export const multiSelectDropdownStateReducer = (state, actionAndChanges) => {
7
- const { changes, type } = actionAndChanges;
8
- switch (type) {
9
- case useSelect.stateChangeTypes.MenuKeyDownSpaceButton:
10
- return Object.assign(Object.assign({}, changes), { isOpen: true, highlightedIndex: state.highlightedIndex });
11
- case useSelect.stateChangeTypes.MenuKeyDownEnter:
12
- case useSelect.stateChangeTypes.ItemClick:
13
- return Object.assign(Object.assign({}, changes), { isOpen: true, highlightedIndex: state.highlightedIndex, inputValue: '' });
14
- case useCombobox.stateChangeTypes.InputKeyDownEnter:
15
- return Object.assign(Object.assign({}, changes), { inputValue: state.inputValue });
16
- case useCombobox.stateChangeTypes.ItemClick:
17
- return Object.assign(Object.assign({}, changes), { isOpen: true, highlightedIndex: state.highlightedIndex, inputValue: '' });
18
- case useCombobox.stateChangeTypes.InputBlur:
19
- return Object.assign({}, changes);
20
- default:
21
- return changes;
22
- }
23
- };
@@ -1,4 +0,0 @@
1
- export * from './DropDownList';
2
- export * from './AsyncDropDownList';
3
- export * from './MultiSelectDropdownList';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DropDownList/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './DropDownList';
2
- export * from './AsyncDropDownList';
3
- export * from './MultiSelectDropdownList';
@@ -1,53 +0,0 @@
1
- import { IDClassNameProps, IOption } from '@rh-support/types/shared';
2
- export interface IDropdownListProps<T> extends IDClassNameProps {
3
- list: Array<IOption<T>>;
4
- selectedItem: IOption<T>;
5
- placeholder?: string;
6
- title: string;
7
- disabled?: boolean;
8
- isLoadingList?: boolean;
9
- searchable?: boolean;
10
- isInValid?: boolean;
11
- required?: boolean;
12
- name?: string;
13
- onOuterClick?: (selectedItem: IOption<T>) => void;
14
- onClearSelection?: () => void;
15
- onChange: (selection: IOption<T>) => any;
16
- onMenuToggle?: () => void;
17
- 'data-tracking-id'?: string;
18
- filterListOnMenuOpen?: boolean;
19
- onInputChange?: (query: string) => void;
20
- paginate?: boolean;
21
- maxResults?: number;
22
- onPaginate?: (resultShown: number, inputVal: string, e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
23
- emptyListLabel?: string;
24
- onInputBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
25
- paginationBtnText?: string;
26
- isAsyncSearch?: boolean;
27
- multiSelect?: boolean;
28
- isSelectedItem?: (item: IOption<T>) => boolean;
29
- label?: string | React.ReactNode;
30
- hasTwoColumns?: boolean;
31
- chipGroupComponent?: React.ReactNode;
32
- hideToggleButton?: boolean;
33
- isExportingPDF?: boolean;
34
- }
35
- export type IMultiSelectOnlyProps<T> = {
36
- selectedItems?: Array<IOption<T>>;
37
- onChange: (selectedItems: IOption<T>[]) => any;
38
- onOuterClick?: (selectedItems: IOption<T>[]) => any;
39
- };
40
- export type IDropdownListBasePropsForMultiSelect<T> = Omit<IDropdownListProps<T>, 'onChange' | 'onOuterClick' | 'multiSelect' | 'selectedItem' | 'isSelectedItem' | 'isAsyncSearch'>;
41
- export type MultiSelectDropdownProps<T> = IDropdownListBasePropsForMultiSelect<T> & IMultiSelectOnlyProps<T>;
42
- export type IAsyncOnlyProps<T> = {
43
- delay?: number;
44
- minLength?: number;
45
- onSearch: (string: any) => void;
46
- promptText?: string;
47
- searchText?: string;
48
- useCache?: boolean;
49
- suggestedItems?: Array<IOption<T>>;
50
- };
51
- export type IDropdownListBasePropsForAsync<T> = Omit<IDropdownListProps<T>, 'isAsyncSearch' | 'searchable' | 'multiSelect'> | MultiSelectDropdownProps<T>;
52
- export type AsyncDropdownProps<T> = Omit<IDropdownListProps<T>, 'isAsyncSearch' | 'searchable' | 'multiSelect'> & IAsyncOnlyProps<T>;
53
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/DropDownList/types.ts"],"names":[],"mappings":"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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { IDropdownListBasePropsForMultiSelect, IMultiSelectOnlyProps } from './types';
3
- export declare function useMulti<OptionType, DropdownPropsType extends IDropdownListBasePropsForMultiSelect<OptionType>>(props: DropdownPropsType & IMultiSelectOnlyProps<OptionType>): DropdownPropsType;
4
- export declare function withMulti<DropdownPropsType extends IDropdownListBasePropsForMultiSelect<OptionType>, OptionType>(WrappedComponent: React.ComponentType<DropdownPropsType>): React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
5
- //# sourceMappingURL=withMulti.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withMulti.d.ts","sourceRoot":"","sources":["../../../src/DropDownList/withMulti.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,oCAAoC,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMtF,wBAAgB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,SAAS,oCAAoC,CAAC,UAAU,CAAC,EAC3G,KAAK,EAAE,iBAAiB,GAAG,qBAAqB,CAAC,UAAU,CAAC,GAC7D,iBAAiB,CA8BnB;AAED,wBAAgB,SAAS,CAAC,iBAAiB,SAAS,oCAAoC,CAAC,UAAU,CAAC,EAAE,UAAU,EAC5G,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,iEAa3D"}
@@ -1,46 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React, { forwardRef } from 'react';
13
- import { itemToString } from './dropdownUtils';
14
- const defaultProps = {
15
- selectedItems: [],
16
- };
17
- export function useMulti(props) {
18
- const { selectedItems, onChange } = props, rest = __rest(props, ["selectedItems", "onChange"]);
19
- const onChangeLocal = (selectedItem) => {
20
- let newItems = (selectedItems || []).slice();
21
- const selectedItemsLabel = props.selectedItems.filter((item) => !item.isNotSelectable).map(itemToString);
22
- const selectedItemLabel = itemToString(selectedItem);
23
- if (selectedItemsLabel.includes(selectedItemLabel)) {
24
- newItems = selectedItems.filter((i) => itemToString(i) !== itemToString(selectedItem));
25
- }
26
- else {
27
- newItems.push(selectedItem);
28
- }
29
- props.onChange && props.onChange(newItems);
30
- };
31
- const onOuterClickLocal = () => {
32
- props.onOuterClick && props.onOuterClick(props.selectedItems);
33
- };
34
- const isSelectedItemLocal = (item) => {
35
- return !item.isNotSelectable && props.selectedItems.map(itemToString).includes(itemToString(item));
36
- };
37
- return Object.assign(Object.assign({}, rest), { multiSelect: true, onChange: onChangeLocal, selectedItem: null, onOuterClick: onOuterClickLocal, isSelectedItem: isSelectedItemLocal });
38
- }
39
- export function withMulti(WrappedComponent) {
40
- // @ts-ignore
41
- const MultiSelectDropdown = forwardRef((props, ref) => (React.createElement(WrappedComponent, Object.assign({}, useMulti(props), { ref: ref }))));
42
- const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
43
- MultiSelectDropdown.displayName = `withMulti${displayName}`;
44
- MultiSelectDropdown.defaultProps = defaultProps;
45
- return MultiSelectDropdown;
46
- }