@rh-support/components 2.0.5 → 2.0.8
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/lib/cjs/AlertMessage/AlertMessage.js +5 -5
- package/lib/cjs/ConfirmationModal/ConfirmationContext.js +13 -41
- package/lib/cjs/ConfirmationModal/ConfirmationDialog.js +5 -5
- package/lib/cjs/CoverSpinner/CoverSpinner.js +1 -1
- package/lib/cjs/CustomContentLoader/CustomContentLoader.js +4 -4
- package/lib/cjs/CustomTextInput/CustomTextInput.js +8 -19
- package/lib/cjs/DropDownList/AsyncDropDownList.js +5 -5
- package/lib/cjs/DropDownList/DropDownList.js +45 -75
- package/lib/cjs/DropDownList/DropdownWrapper.js +7 -18
- package/lib/cjs/DropDownList/MultiSelectDropdownList.js +3 -3
- package/lib/cjs/DropDownList/SearchableList.js +41 -55
- package/lib/cjs/DropDownList/SelectList.js +15 -26
- package/lib/cjs/DropDownList/async.js +28 -38
- package/lib/cjs/DropDownList/dropdownUtils.js +9 -20
- package/lib/cjs/DropDownList/withMulti.js +15 -26
- package/lib/cjs/ErrorBoundary/ErrorBoundary.js +18 -47
- package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.js +10 -10
- package/lib/cjs/ErrorPages/Generic403.js +2 -2
- package/lib/cjs/FeedbackForm/FeedbackForm.js +24 -52
- package/lib/cjs/Functional/CaseContactsSelectorExternal.js +81 -154
- package/lib/cjs/InlineEdit/InlineEdit.js +56 -142
- package/lib/cjs/InlineEdit/NewInlineEdit.js +60 -145
- package/lib/cjs/LanguageSelector/LanguageSelector.js +10 -26
- package/lib/cjs/LoadingDots/LoadingDots.js +3 -3
- package/lib/cjs/LoadingIndicator/LoadingIndicator.js +3 -3
- package/lib/cjs/LoginModal/LoginModal.js +3 -3
- package/lib/cjs/MarkdownEditor/MarkdownEditor.js +113 -165
- package/lib/cjs/MoreOrLess/MoreOrLess.js +20 -40
- package/lib/cjs/PaginatedList/PaginatedList.js +15 -31
- package/lib/cjs/PaginationCompact/PaginationCompact.js +14 -31
- package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.js +14 -14
- package/lib/cjs/ProgressBar/CircularProgressBar/Path.js +20 -18
- package/lib/cjs/ProgressBar/ProgressBar.js +8 -19
- package/lib/cjs/PromisifyModal/PromisifyModal.js +19 -36
- package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.js +5 -5
- package/lib/cjs/SubscriptionAbuse/const.js +3 -3
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.js +8 -24
- package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.js +50 -120
- package/lib/cjs/Table/PFTable.js +52 -89
- package/lib/cjs/Table/Table.js +12 -29
- package/lib/cjs/Table/TableColumnSelector.js +14 -15
- package/lib/cjs/Table/TablePagination.js +8 -8
- package/lib/cjs/Table/TableProvider.js +6 -6
- package/lib/cjs/TermsAndConditions/AcceptTermsModal.js +46 -100
- package/lib/cjs/TextAreaAutosize/TextAreaAutosize.js +35 -62
- package/lib/cjs/TextAreaResizable/TextAreaResizable.js +9 -25
- package/lib/cjs/ToastNotification/ToastNotification.js +35 -70
- package/lib/cjs/TopContentSearch/TopContentSearch.js +48 -113
- package/lib/cjs/ValueChangedIcon/ValueChangedIcon.js +13 -29
- package/lib/cjs/helperFunctions/errorMessage.js +13 -13
- package/lib/cjs/hooks/useBreakpoint.js +26 -43
- package/lib/cjs/hooks/useCopyToClipboard.js +8 -24
- package/lib/cjs/hooks/useDebounce.js +13 -38
- package/lib/cjs/hooks/useFetch.js +47 -123
- package/lib/cjs/hooks/useForceUpdate.js +2 -18
- package/lib/cjs/hooks/useForkRef.js +3 -3
- package/lib/cjs/hooks/useIsMounted.js +4 -4
- package/lib/cjs/hooks/useLRUCache.js +11 -11
- package/lib/cjs/hooks/useLocalStorage.js +7 -23
- package/lib/cjs/hooks/useOnScreen.js +5 -24
- package/lib/cjs/hooks/usePolling.js +8 -30
- package/lib/cjs/hooks/usePrevious.js +3 -3
- package/lib/cjs/hooks/useTitle.js +4 -4
- package/lib/cjs/hooks/useUndo.js +49 -72
- package/lib/esm/AlertMessage/AlertMessage.js +2 -2
- package/package.json +9 -10
|
@@ -1,67 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
const caret_down_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/caret-down-icon"));
|
|
7
|
+
const times_circle_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/times-circle-icon"));
|
|
8
|
+
const downshift_1 = require("downshift");
|
|
9
|
+
const includes_1 = __importDefault(require("lodash/includes"));
|
|
10
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const LoadingIndicator_1 = require("../LoadingIndicator/LoadingIndicator");
|
|
13
|
+
const dropdownUtils_1 = require("./dropdownUtils");
|
|
14
|
+
const DropdownWrapper_1 = __importDefault(require("./DropdownWrapper"));
|
|
26
15
|
function SearchableList(props) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return includes_1.default(labelLC, inputValueLC);
|
|
35
|
-
};
|
|
16
|
+
const doesMatchInput = (inputVal) => (item) => {
|
|
17
|
+
// Should always keep non-searchable, or item with no labels
|
|
18
|
+
if (item.isNotSearchable || item.label === null || item.label === undefined)
|
|
19
|
+
return true;
|
|
20
|
+
const inputValueLC = inputVal ? inputVal.trim().toLowerCase() : '';
|
|
21
|
+
const labelLC = dropdownUtils_1.itemToString(item).trim().toLowerCase();
|
|
22
|
+
return includes_1.default(labelLC, inputValueLC);
|
|
36
23
|
};
|
|
37
|
-
|
|
24
|
+
const onIsOpenChange = (changes) => {
|
|
38
25
|
if (!changes.isOpen && changes.type !== downshift_1.useCombobox.stateChangeTypes.ItemClick) {
|
|
39
26
|
props.onOuterClick && props.onOuterClick(props.selectedItem);
|
|
40
27
|
}
|
|
41
28
|
};
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
const comboboxStateReducer = (state, actionAndChanges) => {
|
|
30
|
+
const { changes, type } = actionAndChanges;
|
|
44
31
|
switch (type) {
|
|
45
32
|
case downshift_1.useCombobox.stateChangeTypes.InputBlur:
|
|
46
|
-
return
|
|
33
|
+
return Object.assign(Object.assign({}, changes), { inputValue: dropdownUtils_1.itemToString(props.selectedItem) && downshift.inputValue !== dropdownUtils_1.itemToString(props.selectedItem)
|
|
47
34
|
? dropdownUtils_1.itemToString(props.selectedItem)
|
|
48
35
|
: state.inputValue });
|
|
49
36
|
case downshift_1.useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
50
|
-
return
|
|
37
|
+
return Object.assign(Object.assign({}, changes), { inputValue: state.inputValue });
|
|
51
38
|
default:
|
|
52
39
|
return changes;
|
|
53
40
|
}
|
|
54
41
|
};
|
|
55
|
-
|
|
42
|
+
const downshift = downshift_1.useCombobox({
|
|
56
43
|
selectedItem: props.selectedItem,
|
|
57
44
|
items: props.itemsList,
|
|
58
45
|
onSelectedItemChange: props.onChange,
|
|
59
|
-
labelId: props.id
|
|
46
|
+
labelId: `${props.id}-label`,
|
|
60
47
|
itemToString: dropdownUtils_1.itemToString,
|
|
61
|
-
onIsOpenChange
|
|
62
|
-
onInputValueChange:
|
|
63
|
-
|
|
64
|
-
var newList = props.searchable && (props.filterListOnMenuOpen || isOpen) && !props.isAsyncSearch
|
|
48
|
+
onIsOpenChange,
|
|
49
|
+
onInputValueChange: ({ inputValue, isOpen }) => {
|
|
50
|
+
const newList = props.searchable && (props.filterListOnMenuOpen || isOpen) && !props.isAsyncSearch
|
|
65
51
|
? props.list.filter(doesMatchInput(inputValue))
|
|
66
52
|
: props.list;
|
|
67
53
|
// for async search we want to make sure that we don't call input change unless the user changes
|
|
@@ -70,30 +56,30 @@ function SearchableList(props) {
|
|
|
70
56
|
},
|
|
71
57
|
stateReducer: props.multiSelect ? dropdownUtils_1.multiSelectDropdownStateReducer : comboboxStateReducer,
|
|
72
58
|
});
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
const { getInputProps, getToggleButtonProps, getMenuProps, getLabelProps, openMenu, isOpen } = downshift;
|
|
60
|
+
const clearSelection = () => (event) => {
|
|
75
61
|
props.onClearSelection && props.onClearSelection();
|
|
76
62
|
// in case of multi select we force input to get cleared on clear button click
|
|
77
63
|
downshift.selectItem(null);
|
|
78
64
|
!isOpen && openMenu();
|
|
79
|
-
};
|
|
80
|
-
|
|
65
|
+
};
|
|
66
|
+
const onInputClick = () => (e) => {
|
|
81
67
|
if (!isOpen) {
|
|
82
68
|
openMenu();
|
|
83
69
|
props.onMenuToggle && props.onMenuToggle();
|
|
84
70
|
}
|
|
85
|
-
};
|
|
86
|
-
|
|
71
|
+
};
|
|
72
|
+
const onInputBlur = () => (e) => {
|
|
87
73
|
props.onInputBlur && props.onInputBlur(e);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return (react_1.default.createElement("div",
|
|
74
|
+
};
|
|
75
|
+
const renderSearchableToggleButton = () => {
|
|
76
|
+
return (react_1.default.createElement("div", Object.assign({}, downshift.getComboboxProps({ className: 'pf-c-select__toggle pf-m-typeahead' })),
|
|
91
77
|
react_1.default.createElement("div", { className: "pf-c-select__toggle-wrapper" },
|
|
92
78
|
props.chipGroupComponent,
|
|
93
|
-
react_1.default.createElement("input",
|
|
79
|
+
react_1.default.createElement("input", Object.assign({}, getInputProps({
|
|
94
80
|
placeholder: props.placeholder,
|
|
95
|
-
className:
|
|
96
|
-
id: props.id
|
|
81
|
+
className: `pf-c-form-control pf-c-select__toggle-typeahead`,
|
|
82
|
+
id: `${props.id}-downshift-search`,
|
|
97
83
|
'aria-invalid': props.isInValid,
|
|
98
84
|
'aria-required': props.required,
|
|
99
85
|
required: props.required,
|
|
@@ -102,12 +88,12 @@ function SearchableList(props) {
|
|
|
102
88
|
onBlur: onInputBlur(),
|
|
103
89
|
})))),
|
|
104
90
|
react_1.default.createElement(LoadingIndicator_1.LoadingIndicator, { isInline: true, show: props.isLoadingList }),
|
|
105
|
-
!isEmpty_1.default(downshift.inputValue) && !props.isLoadingList && (react_1.default.createElement("button", { className: "pf-c-button pf-m-plain pf-c-select__toggle-clear", onClick: clearSelection(), "aria-label": "clear selection", type: "button", title: "Clear selection", disabled: props.disabled, "data-tracking-id": props['data-tracking-id']
|
|
91
|
+
!isEmpty_1.default(downshift.inputValue) && !props.isLoadingList && (react_1.default.createElement("button", { className: "pf-c-button pf-m-plain pf-c-select__toggle-clear", onClick: clearSelection(), "aria-label": "clear selection", type: "button", title: "Clear selection", disabled: props.disabled, "data-tracking-id": `${props['data-tracking-id']}-clear` },
|
|
106
92
|
react_1.default.createElement(times_circle_icon_1.default, null))),
|
|
107
|
-
!props.hideToggleButton && (react_1.default.createElement("button",
|
|
93
|
+
!props.hideToggleButton && (react_1.default.createElement("button", Object.assign({ type: "button" }, getToggleButtonProps({
|
|
108
94
|
disabled: props.disabled || props.isLoadingList,
|
|
109
95
|
className: 'pf-c-button pf-c-select__toggle-button pf-m-plain',
|
|
110
|
-
onClick: props.onMenuToggle ?
|
|
96
|
+
onClick: props.onMenuToggle ? () => props.onMenuToggle() : dropdownUtils_1.noop,
|
|
111
97
|
})),
|
|
112
98
|
react_1.default.createElement(caret_down_icon_1.default, null)))));
|
|
113
99
|
};
|
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
const caret_down_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/caret-down-icon"));
|
|
7
|
+
const downshift_1 = require("downshift");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const LoadingIndicator_1 = require("../LoadingIndicator/LoadingIndicator");
|
|
10
|
+
const dropdownUtils_1 = require("./dropdownUtils");
|
|
11
|
+
const DropdownWrapper_1 = __importDefault(require("./DropdownWrapper"));
|
|
23
12
|
function SelectList(props) {
|
|
24
|
-
|
|
13
|
+
const onIsOpenChange = (changes) => {
|
|
25
14
|
if (!changes.isOpen && changes.type !== downshift_1.useSelect.stateChangeTypes.ItemClick) {
|
|
26
15
|
props.onOuterClick && props.onOuterClick(props.selectedItem);
|
|
27
16
|
}
|
|
28
17
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
const downshift = downshift_1.useSelect(Object.assign({ selectedItem: props.selectedItem, items: props.list, onIsOpenChange, onSelectedItemChange: props.onChange, labelId: `${props.id}-label`, itemToString: dropdownUtils_1.itemToString }, (props.multiSelect && { stateReducer: dropdownUtils_1.multiSelectDropdownStateReducer })));
|
|
19
|
+
const { getToggleButtonProps, getLabelProps, getMenuProps, isOpen } = downshift;
|
|
20
|
+
const renderToggleButton = () => {
|
|
32
21
|
var _a;
|
|
33
|
-
return (react_1.default.createElement("button",
|
|
34
|
-
id: props.id
|
|
35
|
-
className:
|
|
22
|
+
return (react_1.default.createElement("button", Object.assign({ type: "button" }, getToggleButtonProps({
|
|
23
|
+
id: `${props.id}-toggle`,
|
|
24
|
+
className: `pf-c-select__toggle ${props.isInValid ? 'form-invalid' : ''}`,
|
|
36
25
|
disabled: props.disabled || props.isLoadingList,
|
|
37
|
-
'aria-label':
|
|
26
|
+
'aria-label': `${isOpen ? 'Close ' + props.title : 'Open ' + props.title}`,
|
|
38
27
|
'aria-invalid': props.isInValid,
|
|
39
28
|
name: props.name,
|
|
40
29
|
title: dropdownUtils_1.itemToString(props.selectedItem) || props.placeholder,
|
|
41
30
|
'data-tracking-id': (_a = props['data-tracking-id']) !== null && _a !== void 0 ? _a : '',
|
|
42
|
-
onClick: props.onMenuToggle ?
|
|
31
|
+
onClick: props.onMenuToggle ? () => props.onMenuToggle() : dropdownUtils_1.noop,
|
|
43
32
|
})),
|
|
44
33
|
react_1.default.createElement("div", { className: "pf-c-select__toggle-wrapper" },
|
|
45
34
|
react_1.default.createElement("span", { className: "pf-c-select__toggle-text" }, dropdownUtils_1.itemToString(props.selectedItem) || (react_1.default.createElement("span", { className: "pf-c-select__placeholder-text" }, props.placeholder)))),
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -45,13 +34,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
34
|
};
|
|
46
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
36
|
exports.withAsync = exports.useAsync = void 0;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
const debounce_1 = __importDefault(require("lodash/debounce"));
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const hooks_1 = require("../hooks");
|
|
40
|
+
const usePrevious_1 = require("../hooks/usePrevious");
|
|
52
41
|
// Most of the code credit goes to
|
|
53
42
|
// https://github.com/ericgio/react-bootstrap-typeahead/blob/master/src/behaviors/async.js
|
|
54
|
-
|
|
43
|
+
const defaultProps = {
|
|
55
44
|
delay: 200,
|
|
56
45
|
minLength: 2,
|
|
57
46
|
promptText: '',
|
|
@@ -59,13 +48,13 @@ var defaultProps = {
|
|
|
59
48
|
useCache: false,
|
|
60
49
|
};
|
|
61
50
|
function useAsync(props) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
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"]);
|
|
52
|
+
const { getFromCache, setInCache, clearCache } = hooks_1.useLRUCache(25);
|
|
53
|
+
const handleSearchDebouncedRef = react_1.useRef();
|
|
54
|
+
const queryRef = react_1.useRef('');
|
|
55
|
+
const forceUpdate = hooks_1.useForceUpdate();
|
|
56
|
+
const prevProps = usePrevious_1.usePrevious(props);
|
|
57
|
+
const handleSearch = react_1.useCallback((query) => {
|
|
69
58
|
queryRef.current = query;
|
|
70
59
|
if (!query || (minLength && query.length < minLength)) {
|
|
71
60
|
return;
|
|
@@ -82,33 +71,33 @@ function useAsync(props) {
|
|
|
82
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
72
|
[forceUpdate, minLength, onSearch, useCache]);
|
|
84
73
|
// Set the debounced search function.
|
|
85
|
-
react_1.useEffect(
|
|
74
|
+
react_1.useEffect(() => {
|
|
86
75
|
handleSearchDebouncedRef.current = debounce_1.default(handleSearch, delay);
|
|
87
|
-
return
|
|
76
|
+
return () => {
|
|
88
77
|
handleSearchDebouncedRef.current && handleSearchDebouncedRef.current.cancel();
|
|
89
78
|
};
|
|
90
79
|
}, [delay, handleSearch]);
|
|
91
|
-
react_1.useEffect(
|
|
80
|
+
react_1.useEffect(() => {
|
|
92
81
|
// Ensure that we've gone from a loading to a completed state. Otherwise
|
|
93
82
|
// an empty response could get cached if the component updates during the
|
|
94
83
|
// request (eg: if the parent re-renders for some reason).
|
|
95
84
|
// NOTE: There is a limitation that empty responses will not be cached.
|
|
96
|
-
|
|
85
|
+
const listToCache = list.filter((item) => !item.isNotSearchable);
|
|
97
86
|
if (!isLoadingList && useCache && queryRef.current && (listToCache || []).length > 0) {
|
|
98
87
|
setInCache(queryRef.current, list);
|
|
99
88
|
}
|
|
100
89
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
90
|
}, [list, isLoadingList, useCache]);
|
|
102
|
-
react_1.useEffect(
|
|
91
|
+
react_1.useEffect(() => {
|
|
103
92
|
if (prevProps && prevProps.useCache && !useCache) {
|
|
104
93
|
clearCache();
|
|
105
94
|
}
|
|
106
|
-
return
|
|
95
|
+
return () => {
|
|
107
96
|
clearCache();
|
|
108
97
|
};
|
|
109
98
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
99
|
}, [useCache]);
|
|
111
|
-
|
|
100
|
+
const getEmptyLabel = () => {
|
|
112
101
|
if (!queryRef.current.length) {
|
|
113
102
|
return props.promptText;
|
|
114
103
|
}
|
|
@@ -117,19 +106,20 @@ function useAsync(props) {
|
|
|
117
106
|
}
|
|
118
107
|
return emptyListLabel;
|
|
119
108
|
};
|
|
120
|
-
|
|
109
|
+
const handleInputBlur = (e) => {
|
|
121
110
|
onInputBlur && onInputBlur(e);
|
|
122
111
|
};
|
|
123
|
-
|
|
112
|
+
const handleClearSelection = () => {
|
|
124
113
|
onClearSelection && onClearSelection();
|
|
125
114
|
queryRef.current = '';
|
|
126
115
|
};
|
|
127
|
-
|
|
116
|
+
const handleInputChange = react_1.useCallback((query) => {
|
|
128
117
|
onInputChange && onInputChange(query);
|
|
129
118
|
handleSearchDebouncedRef.current && handleSearchDebouncedRef.current(query);
|
|
130
119
|
}, [onInputChange]);
|
|
131
|
-
|
|
132
|
-
return
|
|
120
|
+
const cachedQuery = getFromCache(queryRef.current);
|
|
121
|
+
return Object.assign(Object.assign({}, otherProps), { isLoadingList,
|
|
122
|
+
minLength, onInputChange: handleInputChange, emptyListLabel: getEmptyLabel(), list: useCache && cachedQuery
|
|
133
123
|
? cachedQuery
|
|
134
124
|
: !queryRef.current
|
|
135
125
|
? (suggestedItems || []).length > 0
|
|
@@ -139,9 +129,9 @@ function useAsync(props) {
|
|
|
139
129
|
}
|
|
140
130
|
exports.useAsync = useAsync;
|
|
141
131
|
function withAsync(WrappedComponent) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
AsyncDropdown.displayName =
|
|
132
|
+
const AsyncDropdown = (props) => (react_1.default.createElement(WrappedComponent, Object.assign({}, useAsync(props))));
|
|
133
|
+
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
134
|
+
AsyncDropdown.displayName = `withAsync${displayName}`;
|
|
145
135
|
AsyncDropdown.defaultProps = defaultProps;
|
|
146
136
|
return AsyncDropdown;
|
|
147
137
|
}
|
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.multiSelectDropdownStateReducer = exports.noop = exports.itemToString = void 0;
|
|
15
|
-
|
|
4
|
+
const downshift_1 = require("downshift");
|
|
16
5
|
function itemToString(item) {
|
|
17
6
|
return item ? item.label : '';
|
|
18
7
|
}
|
|
19
8
|
exports.itemToString = itemToString;
|
|
20
|
-
|
|
9
|
+
const noop = () => { };
|
|
21
10
|
exports.noop = noop;
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
const multiSelectDropdownStateReducer = (state, actionAndChanges) => {
|
|
12
|
+
const { changes, type } = actionAndChanges;
|
|
24
13
|
switch (type) {
|
|
25
14
|
case downshift_1.useSelect.stateChangeTypes.MenuKeyDownSpaceButton:
|
|
26
|
-
return
|
|
15
|
+
return Object.assign(Object.assign({}, changes), { isOpen: true, highlightedIndex: state.highlightedIndex });
|
|
27
16
|
case downshift_1.useSelect.stateChangeTypes.MenuKeyDownEnter:
|
|
28
17
|
case downshift_1.useSelect.stateChangeTypes.ItemClick:
|
|
29
|
-
return
|
|
18
|
+
return Object.assign(Object.assign({}, changes), { isOpen: true, highlightedIndex: state.highlightedIndex, inputValue: '' });
|
|
30
19
|
case downshift_1.useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
31
|
-
return
|
|
20
|
+
return Object.assign(Object.assign({}, changes), { inputValue: state.inputValue });
|
|
32
21
|
case downshift_1.useCombobox.stateChangeTypes.ItemClick:
|
|
33
|
-
return
|
|
22
|
+
return Object.assign(Object.assign({}, changes), { isOpen: true, highlightedIndex: state.highlightedIndex, inputValue: '' });
|
|
34
23
|
case downshift_1.useCombobox.stateChangeTypes.InputBlur:
|
|
35
|
-
return
|
|
24
|
+
return Object.assign({}, changes);
|
|
36
25
|
default:
|
|
37
26
|
return changes;
|
|
38
27
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -42,38 +31,38 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
42
31
|
};
|
|
43
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
33
|
exports.withMulti = exports.useMulti = void 0;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const react_1 = __importStar(require("react"));
|
|
35
|
+
const dropdownUtils_1 = require("./dropdownUtils");
|
|
36
|
+
const defaultProps = {
|
|
48
37
|
selectedItems: [],
|
|
49
38
|
};
|
|
50
39
|
function useMulti(props) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
const { selectedItems, onChange } = props, rest = __rest(props, ["selectedItems", "onChange"]);
|
|
41
|
+
const onChangeLocal = (selectedItem) => {
|
|
42
|
+
let newItems = (selectedItems || []).slice();
|
|
43
|
+
const selectedItemsLabel = props.selectedItems.filter((item) => !item.isNotSelectable).map(dropdownUtils_1.itemToString);
|
|
44
|
+
const selectedItemLabel = dropdownUtils_1.itemToString(selectedItem);
|
|
56
45
|
if (selectedItemsLabel.includes(selectedItemLabel)) {
|
|
57
|
-
newItems = selectedItems.filter(
|
|
46
|
+
newItems = selectedItems.filter((i) => dropdownUtils_1.itemToString(i) !== dropdownUtils_1.itemToString(selectedItem));
|
|
58
47
|
}
|
|
59
48
|
else {
|
|
60
49
|
newItems.push(selectedItem);
|
|
61
50
|
}
|
|
62
51
|
props.onChange && props.onChange(newItems);
|
|
63
52
|
};
|
|
64
|
-
|
|
53
|
+
const onOuterClickLocal = () => {
|
|
65
54
|
props.onOuterClick && props.onOuterClick(props.selectedItems);
|
|
66
55
|
};
|
|
67
|
-
|
|
56
|
+
const isSelectedItemLocal = (item) => {
|
|
68
57
|
return !item.isNotSelectable && props.selectedItems.map(dropdownUtils_1.itemToString).includes(dropdownUtils_1.itemToString(item));
|
|
69
58
|
};
|
|
70
|
-
return
|
|
59
|
+
return Object.assign(Object.assign({}, rest), { multiSelect: true, onChange: onChangeLocal, selectedItem: null, onOuterClick: onOuterClickLocal, isSelectedItem: isSelectedItemLocal });
|
|
71
60
|
}
|
|
72
61
|
exports.useMulti = useMulti;
|
|
73
62
|
function withMulti(WrappedComponent) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
MultiSelectDropdown.displayName =
|
|
63
|
+
const MultiSelectDropdown = react_1.forwardRef((props, ref) => (react_1.default.createElement(WrappedComponent, Object.assign({}, useMulti(props), { ref: ref }))));
|
|
64
|
+
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
65
|
+
MultiSelectDropdown.displayName = `withMulti${displayName}`;
|
|
77
66
|
MultiSelectDropdown.defaultProps = defaultProps;
|
|
78
67
|
return MultiSelectDropdown;
|
|
79
68
|
}
|
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
3
|
if (k2 === undefined) k2 = k;
|
|
30
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -46,25 +20,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
46
20
|
};
|
|
47
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
22
|
exports.ErrorBoundary = void 0;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_this.state = { hasError: false };
|
|
58
|
-
return _this;
|
|
23
|
+
const hydrajs_1 = require("@cee-eng/hydrajs");
|
|
24
|
+
const utils_1 = require("@rh-support/utils");
|
|
25
|
+
const react_1 = __importStar(require("react"));
|
|
26
|
+
const ErrorBoundaryFallbackComponent_1 = require("./ErrorBoundaryFallbackComponent");
|
|
27
|
+
class ErrorBoundary extends react_1.Component {
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super(props);
|
|
30
|
+
this.state = { hasError: false };
|
|
59
31
|
}
|
|
60
|
-
|
|
32
|
+
static getDerivedStateFromError() {
|
|
61
33
|
// Update state so the next render will show the fallback UI.
|
|
62
34
|
return { hasError: true };
|
|
63
|
-
}
|
|
64
|
-
|
|
35
|
+
}
|
|
36
|
+
componentDidCatch(error, errorInfo) {
|
|
65
37
|
if (hydrajs_1.Env.isLocalEnv())
|
|
66
38
|
return;
|
|
67
|
-
|
|
39
|
+
const { onError } = this.props;
|
|
68
40
|
if (typeof onError === 'function') {
|
|
69
41
|
try {
|
|
70
42
|
onError.call(this, error, errorInfo || '');
|
|
@@ -78,14 +50,13 @@ var ErrorBoundary = /** @class */ (function (_super) {
|
|
|
78
50
|
package_version: utils_1.getAppVersion(),
|
|
79
51
|
},
|
|
80
52
|
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
const { children, FallbackComponent } = this.props;
|
|
84
56
|
if (this.state.hasError) {
|
|
85
|
-
return this.props.FallbackComponent ? (react_1.default.createElement(FallbackComponent, null)) : (react_1.default.createElement(ErrorBoundaryFallbackComponent_1.ErrorBoundaryFallbackComponent,
|
|
57
|
+
return this.props.FallbackComponent ? (react_1.default.createElement(FallbackComponent, null)) : (react_1.default.createElement(ErrorBoundaryFallbackComponent_1.ErrorBoundaryFallbackComponent, Object.assign({ isPageLevelError: this.props.isPageLevelError }, this.props.errorMsgInfo)));
|
|
86
58
|
}
|
|
87
59
|
return children || null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}(react_1.Component));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
91
62
|
exports.ErrorBoundary = ErrorBoundary;
|
|
@@ -4,22 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ErrorBoundaryFallbackComponent = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
8
|
+
const exclamation_circle_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/exclamation-circle-icon"));
|
|
9
|
+
const global_danger_color_200_1 = __importDefault(require("@patternfly/react-tokens/dist/js/global_danger_color_200"));
|
|
10
|
+
const global_info_color_200_1 = __importDefault(require("@patternfly/react-tokens/dist/js/global_info_color_200"));
|
|
11
|
+
const global_warning_color_200_1 = __importDefault(require("@patternfly/react-tokens/dist/js/global_warning_color_200"));
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const react_i18next_1 = require("react-i18next");
|
|
14
|
+
const defaultProps = {
|
|
15
15
|
errorType: 'error',
|
|
16
16
|
title: 'Unexpected Error Occured',
|
|
17
17
|
message: 'There was an unexpected error. Please try refreshing the page.',
|
|
18
18
|
isPageLevelError: false,
|
|
19
19
|
};
|
|
20
20
|
function ErrorBoundaryFallbackComponent(props) {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const { t } = react_i18next_1.useTranslation();
|
|
22
|
+
const getIconColor = () => {
|
|
23
23
|
switch (props.errorType) {
|
|
24
24
|
case 'info':
|
|
25
25
|
return global_info_color_200_1.default.value;
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Generic403 = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_i18next_1 = require("react-i18next");
|
|
9
9
|
function Generic403() {
|
|
10
10
|
return (react_1.default.createElement("div", { className: "container" },
|
|
11
11
|
react_1.default.createElement("h2", null,
|