@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
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AlertMessage = exports.AlertType = void 0;
|
|
7
7
|
require("./AlertMessage.css");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
10
|
var AlertType;
|
|
11
11
|
(function (AlertType) {
|
|
12
12
|
AlertType["DANGER"] = "danger";
|
|
@@ -14,7 +14,7 @@ var AlertType;
|
|
|
14
14
|
AlertType["INFO"] = "info";
|
|
15
15
|
AlertType["SUCCESS"] = "success";
|
|
16
16
|
})(AlertType = exports.AlertType || (exports.AlertType = {}));
|
|
17
|
-
|
|
17
|
+
const defaultProps = {
|
|
18
18
|
className: '',
|
|
19
19
|
show: false,
|
|
20
20
|
};
|
|
@@ -23,8 +23,8 @@ function AlertMessage(props) {
|
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
// If there is no title then the children node becomes the title to have a better styling
|
|
26
|
-
|
|
27
|
-
return (react_1.default.createElement(react_core_1.Alert, { label: props.title, className: props.className, variant: props.variant, title:
|
|
26
|
+
const alertMsgTitle = props.title || props.children;
|
|
27
|
+
return (react_1.default.createElement(react_core_1.Alert, { label: props.title, className: props.className, variant: props.variant, title: alertMsgTitle, isInline: props.isInline, actionClose: !!props.onClose ? react_1.default.createElement(react_core_1.AlertActionCloseButton, { onClose: props.onClose }) : null }, props.title ? props.children : react_1.default.createElement(react_1.default.Fragment, null)));
|
|
28
28
|
}
|
|
29
29
|
exports.AlertMessage = AlertMessage;
|
|
30
30
|
AlertMessage.defaultProps = defaultProps;
|
|
@@ -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]; } });
|
|
@@ -29,46 +18,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
18
|
__setModuleDefault(result, mod);
|
|
30
19
|
return result;
|
|
31
20
|
};
|
|
32
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
33
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
34
|
-
if (!m) return o;
|
|
35
|
-
var i = m.call(o), r, ar = [], e;
|
|
36
|
-
try {
|
|
37
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
38
|
-
}
|
|
39
|
-
catch (error) { e = { error: error }; }
|
|
40
|
-
finally {
|
|
41
|
-
try {
|
|
42
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
43
|
-
}
|
|
44
|
-
finally { if (e) throw e.error; }
|
|
45
|
-
}
|
|
46
|
-
return ar;
|
|
47
|
-
};
|
|
48
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
22
|
exports.ConfirmationServiceProvider = exports.useConfirmation = void 0;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
const ConfirmationDialog_1 = require("./ConfirmationDialog");
|
|
25
|
+
const ConfirmationServiceContext = react_1.default.createContext(Promise.reject);
|
|
26
|
+
const useConfirmation = () => react_1.useContext(ConfirmationServiceContext);
|
|
54
27
|
exports.useConfirmation = useConfirmation;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var openConfirmation = function (options) {
|
|
28
|
+
const ConfirmationServiceProvider = ({ children }) => {
|
|
29
|
+
const [confirmationState, setConfirmationState] = react_1.useState(null);
|
|
30
|
+
const awaitingPromiseRef = react_1.useRef();
|
|
31
|
+
const openConfirmation = (options) => {
|
|
60
32
|
setConfirmationState(options);
|
|
61
|
-
return new Promise(
|
|
62
|
-
awaitingPromiseRef.current = { resolve
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
awaitingPromiseRef.current = { resolve, reject };
|
|
63
35
|
});
|
|
64
36
|
};
|
|
65
|
-
|
|
37
|
+
const handleClose = () => {
|
|
66
38
|
if (confirmationState.catchOnCancel && awaitingPromiseRef.current) {
|
|
67
39
|
awaitingPromiseRef.current.reject();
|
|
68
40
|
}
|
|
69
41
|
setConfirmationState(null);
|
|
70
42
|
};
|
|
71
|
-
|
|
43
|
+
const handleConfirm = () => {
|
|
72
44
|
if (awaitingPromiseRef.current) {
|
|
73
45
|
awaitingPromiseRef.current.resolve();
|
|
74
46
|
}
|
|
@@ -76,6 +48,6 @@ var ConfirmationServiceProvider = function (_a) {
|
|
|
76
48
|
};
|
|
77
49
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
78
50
|
react_1.default.createElement(ConfirmationServiceContext.Provider, { value: openConfirmation, children: children }),
|
|
79
|
-
react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog,
|
|
51
|
+
react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, Object.assign({ open: Boolean(confirmationState), onConfirm: handleConfirm, onClose: handleClose }, confirmationState))));
|
|
80
52
|
};
|
|
81
53
|
exports.ConfirmationServiceProvider = ConfirmationServiceProvider;
|
|
@@ -4,17 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ConfirmationDialog = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_i18next_1 = require("react-i18next");
|
|
10
|
+
const defaultProps = {
|
|
11
11
|
confirmText: 'Confirm',
|
|
12
12
|
cancelText: 'Cancel',
|
|
13
13
|
confirmButtonVariant: react_core_1.ButtonVariant.primary,
|
|
14
14
|
cancelButtonVariant: react_core_1.ButtonVariant.link,
|
|
15
15
|
};
|
|
16
16
|
function ConfirmationDialog(props) {
|
|
17
|
-
|
|
17
|
+
const { t } = react_i18next_1.useTranslation();
|
|
18
18
|
return (react_1.default.createElement(react_core_1.Modal, { width: '50%', "aria-describedby": "se-confirm-dialog", "aria-label": t('confirmation modal'), title: props.title || null, isOpen: props.open, onClose: props.onClose, actions: [
|
|
19
19
|
react_1.default.createElement(react_core_1.Button, { key: "confirm", onClick: props.onConfirm, variant: props.confirmButtonVariant },
|
|
20
20
|
react_1.default.createElement(react_i18next_1.Trans, null, props.confirmText)),
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CoverSpinner = void 0;
|
|
7
7
|
require("./CoverSpinner.css");
|
|
8
|
-
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
9
|
function CoverSpinner() {
|
|
10
10
|
return (react_1.default.createElement("div", { className: "cover-spin", role: "alert" },
|
|
11
11
|
react_1.default.createElement("div", { className: "spinner" })));
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CustomContentLoader = exports.OverviewContentLoader = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
9
|
function OverviewContentLoader() {
|
|
10
10
|
return (react_1.default.createElement("div", { style: { width: '100%', position: 'relative' } },
|
|
11
11
|
react_1.default.createElement("div", { style: { width: '70%', height: '900px', position: 'relative' } },
|
|
@@ -54,8 +54,8 @@ function OverviewContentLoader() {
|
|
|
54
54
|
}
|
|
55
55
|
exports.OverviewContentLoader = OverviewContentLoader;
|
|
56
56
|
function CustomContentLoader(props) {
|
|
57
|
-
|
|
58
|
-
props.rectangles.map(
|
|
57
|
+
const children = (props.rectangles &&
|
|
58
|
+
props.rectangles.map((obj) => (react_1.default.createElement(react_core_1.Skeleton, { height: obj.height, width: obj.width, style: { top: obj.y, left: obj.x } })))) ||
|
|
59
59
|
props.children || (react_1.default.createElement(react_core_1.Skeleton, { height: "100px", width: "400px", style: { position: 'relative', marginBottom: '50px' } }));
|
|
60
60
|
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
61
61
|
}
|
|
@@ -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 __rest = (this && this.__rest) || function (s, e) {
|
|
14
3
|
var t = {};
|
|
15
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -26,20 +15,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
15
|
};
|
|
27
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
17
|
exports.CustomTextInput = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
19
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
20
|
+
const react_1 = __importDefault(require("react"));
|
|
21
|
+
const CustomTextInput = (props) => {
|
|
33
22
|
// To set defaultProps
|
|
34
|
-
|
|
23
|
+
const { onChange, isSpaceAllowed = false, isRequired, className, type, maxLength, value, isDisabled, placeholder, validated, name } = props, rest = __rest(props, ["onChange", "isSpaceAllowed", "isRequired", "className", "type", "maxLength", "value", "isDisabled", "placeholder", "validated", "name"]);
|
|
35
24
|
// To handle on input change
|
|
36
|
-
|
|
25
|
+
const onTextInputChange = (value, event) => {
|
|
37
26
|
onChange(value, event);
|
|
38
27
|
event.preventDefault();
|
|
39
28
|
return [];
|
|
40
29
|
};
|
|
41
30
|
// Function to check for validity
|
|
42
|
-
|
|
31
|
+
const validatedCheck = () => {
|
|
43
32
|
if (!isEmpty_1.default(value)) {
|
|
44
33
|
if (validated === 'error') {
|
|
45
34
|
return 'error';
|
|
@@ -54,6 +43,6 @@ var CustomTextInput = function (props) {
|
|
|
54
43
|
return validated;
|
|
55
44
|
}
|
|
56
45
|
};
|
|
57
|
-
return (react_1.default.createElement(react_core_1.TextInput,
|
|
46
|
+
return (react_1.default.createElement(react_core_1.TextInput, Object.assign({}, rest, { isRequired: isRequired, className: className, type: type, maxLength: maxLength, value: value, isDisabled: isDisabled, "aria-label": props['aria-label'], placeholder: placeholder, onChange: onTextInputChange, validated: validatedCheck(), name: name })));
|
|
58
47
|
};
|
|
59
48
|
exports.CustomTextInput = CustomTextInput;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AsyncMultiDropDownList = exports.AsyncDropDownList = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const async_1 = require("./async");
|
|
5
|
+
const DropDownList_1 = require("./DropDownList");
|
|
6
|
+
const MultiSelectDropdownList_1 = require("./MultiSelectDropdownList");
|
|
7
|
+
const AsyncDropDownList = async_1.withAsync(DropDownList_1.Dropdown);
|
|
8
8
|
exports.AsyncDropDownList = AsyncDropDownList;
|
|
9
|
-
|
|
9
|
+
const AsyncMultiDropDownList = async_1.withAsync(MultiSelectDropdownList_1.MultiSelectDropDownList);
|
|
10
10
|
exports.AsyncMultiDropDownList = AsyncMultiDropDownList;
|
|
@@ -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]; } });
|
|
@@ -29,42 +18,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
18
|
__setModuleDefault(result, mod);
|
|
30
19
|
return result;
|
|
31
20
|
};
|
|
32
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
33
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
34
|
-
if (!m) return o;
|
|
35
|
-
var i = m.call(o), r, ar = [], e;
|
|
36
|
-
try {
|
|
37
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
38
|
-
}
|
|
39
|
-
catch (error) { e = { error: error }; }
|
|
40
|
-
finally {
|
|
41
|
-
try {
|
|
42
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
43
|
-
}
|
|
44
|
-
finally { if (e) throw e.error; }
|
|
45
|
-
}
|
|
46
|
-
return ar;
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
49
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
50
|
-
to[j] = from[i];
|
|
51
|
-
return to;
|
|
52
|
-
};
|
|
53
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
23
|
};
|
|
56
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
25
|
exports.Dropdown = void 0;
|
|
58
26
|
require("./dropdownList.css");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
27
|
+
const check_icon_1 = __importDefault(require("@patternfly/react-icons/dist/js/icons/check-icon"));
|
|
28
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
29
|
+
const map_1 = __importDefault(require("lodash/map"));
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const react_i18next_1 = require("react-i18next");
|
|
32
|
+
const dropdownUtils_1 = require("./dropdownUtils");
|
|
33
|
+
const SearchableList_1 = __importDefault(require("./SearchableList"));
|
|
34
|
+
const SelectList_1 = __importDefault(require("./SelectList"));
|
|
35
|
+
const defaultProps = {
|
|
68
36
|
className: '',
|
|
69
37
|
id: '',
|
|
70
38
|
searchable: false,
|
|
@@ -86,27 +54,26 @@ var defaultProps = {
|
|
|
86
54
|
};
|
|
87
55
|
function Dropdown(props) {
|
|
88
56
|
var _a, _b, _c;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var selectedItem = _a.selectedItem;
|
|
57
|
+
const [resultsShown, setResultsShown] = react_1.useState(props.maxResults);
|
|
58
|
+
const [itemsList, setItemsList] = react_1.useState(props.list);
|
|
59
|
+
const onChangeLocal = ({ selectedItem, }) => {
|
|
93
60
|
selectedItem && props.onChange && props.onChange(selectedItem);
|
|
94
61
|
};
|
|
95
|
-
react_1.useEffect(
|
|
62
|
+
react_1.useEffect(() => {
|
|
96
63
|
setItemsList(props.list);
|
|
97
64
|
}, [props.list]);
|
|
98
|
-
|
|
65
|
+
const onPaginatonButtonClick = (e, downshift) => {
|
|
99
66
|
e.stopPropagation();
|
|
100
|
-
|
|
67
|
+
const finalCount = resultsShown + props.maxResults;
|
|
101
68
|
setResultsShown(finalCount);
|
|
102
69
|
props.onPaginate && props.onPaginate(finalCount, downshift.inputValue, e);
|
|
103
70
|
};
|
|
104
|
-
|
|
71
|
+
const isSelectedItemLocal = (item) => {
|
|
105
72
|
return !item.isNotSelectable && dropdownUtils_1.itemToString(props.selectedItem) === dropdownUtils_1.itemToString(item);
|
|
106
73
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
74
|
+
const isSelectedItem = props.isSelectedItem || isSelectedItemLocal;
|
|
75
|
+
const getListItemClassNames = (downshift, item, itemIndex) => {
|
|
76
|
+
let toReturn = 'downshift-item pf-c-select__menu-item';
|
|
110
77
|
toReturn += item.additionalInfo ? ' pf-m-description' : '';
|
|
111
78
|
toReturn += isSelectedItem(item) ? ' pf-m-selected' : '';
|
|
112
79
|
toReturn += item.disabled ? ' pf-m-disabled' : '';
|
|
@@ -114,58 +81,61 @@ function Dropdown(props) {
|
|
|
114
81
|
toReturn += item.className ? item.className : '';
|
|
115
82
|
return toReturn;
|
|
116
83
|
};
|
|
117
|
-
|
|
84
|
+
const onInputChangeLocal = (items, inputValue) => {
|
|
118
85
|
setResultsShown(props.maxResults);
|
|
119
86
|
setItemsList(items);
|
|
120
87
|
props.onInputChange && props.onInputChange(inputValue);
|
|
121
88
|
};
|
|
122
|
-
|
|
123
|
-
|
|
89
|
+
const renderListItems = (downshift) => {
|
|
90
|
+
const listToRender = [];
|
|
124
91
|
if (!downshift.isOpen)
|
|
125
92
|
return [];
|
|
126
|
-
|
|
127
|
-
|
|
93
|
+
let optionsToRender = itemsList;
|
|
94
|
+
const shouldPaginate = props.paginate && resultsShown < optionsToRender.length;
|
|
128
95
|
optionsToRender = props.paginate ? optionsToRender.slice(0, resultsShown) : optionsToRender;
|
|
129
|
-
optionsToRender.filter(
|
|
96
|
+
optionsToRender.filter((item) => !item.isNotSearchable).length === 0 &&
|
|
130
97
|
props.emptyListLabel &&
|
|
131
98
|
listToRender.push(react_1.default.createElement("li", { key: "empty-label", className: "pf-u-p-sm" },
|
|
132
99
|
react_1.default.createElement(react_i18next_1.Trans, null, props.emptyListLabel)));
|
|
133
|
-
listToRender.push
|
|
134
|
-
|
|
100
|
+
listToRender.push(...map_1.default(optionsToRender, (item, index) => {
|
|
101
|
+
const itemProps = item.isNonActionable
|
|
135
102
|
? {}
|
|
136
103
|
: downshift.getItemProps({
|
|
137
|
-
item
|
|
138
|
-
index
|
|
104
|
+
item,
|
|
105
|
+
index,
|
|
139
106
|
disabled: item.disabled,
|
|
140
107
|
className: getListItemClassNames(downshift, item, index),
|
|
141
108
|
});
|
|
142
|
-
return (react_1.default.createElement("li", { className: item.actionItem ? 'pf-c-select__menu-wrapper' : '', role: "presentation", key: index
|
|
109
|
+
return (react_1.default.createElement("li", { className: item.actionItem ? 'pf-c-select__menu-wrapper' : '', role: "presentation", key: `${index}-${props.id}-${dropdownUtils_1.itemToString(item)}` },
|
|
143
110
|
item.isNonActionable ? (isEmpty_1.default(item.children) ? dropdownUtils_1.itemToString(item) : item.children) : null,
|
|
144
|
-
props.multiSelect && !item.isNotSelectable && !item.isNonActionable && (react_1.default.createElement("div",
|
|
111
|
+
props.multiSelect && !item.isNotSelectable && !item.isNonActionable && (react_1.default.createElement("div", Object.assign({}, itemProps),
|
|
145
112
|
react_1.default.createElement("div", { className: item.additionalInfo ? 'pf-c-select__menu-item-main' : '' },
|
|
146
113
|
react_1.default.createElement("input", { disabled: item.disabled === true, className: "pf-c-check__input pf-u-mr-sm", checked: isSelectedItem(item), onChange: dropdownUtils_1.noop, type: "checkbox" }),
|
|
147
114
|
isEmpty_1.default(item.children) ? dropdownUtils_1.itemToString(item) : item.children),
|
|
148
115
|
item.additionalInfo && (react_1.default.createElement("div", { className: "pf-c-select__menu-item-description" }, item.additionalInfo)))),
|
|
149
|
-
!props.multiSelect && !item.isNonActionable && (react_1.default.createElement("button",
|
|
116
|
+
!props.multiSelect && !item.isNonActionable && (react_1.default.createElement("button", Object.assign({}, itemProps, { type: "button", title: dropdownUtils_1.itemToString(item) }),
|
|
150
117
|
react_1.default.createElement("div", { className: item.additionalInfo ? 'pf-c-select__menu-item-main' : '' },
|
|
151
118
|
isEmpty_1.default(item.children) ? dropdownUtils_1.itemToString(item) : item.children,
|
|
152
119
|
isSelectedItem(item) && (react_1.default.createElement("span", { className: "pf-c-select__menu-item-icon" },
|
|
153
120
|
react_1.default.createElement(check_icon_1.default, { "aria-hidden": true })))),
|
|
154
121
|
item.additionalInfo && (react_1.default.createElement("div", { className: "pf-c-select__menu-item-description" }, item.additionalInfo)))),
|
|
155
122
|
item.actionItem ? react_1.default.cloneElement(item.actionItem, { disabled: item.disabled }) : null));
|
|
156
|
-
}))
|
|
157
|
-
shouldPaginate &&
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
react_1.default.createElement("
|
|
161
|
-
react_1.default.createElement(
|
|
162
|
-
|
|
123
|
+
}));
|
|
124
|
+
shouldPaginate &&
|
|
125
|
+
listToRender.push(...[
|
|
126
|
+
react_1.default.createElement("li", { key: "separator", className: "dropdown-divider", role: "separator" }),
|
|
127
|
+
react_1.default.createElement("li", { key: "pagination-item", className: "downshift-pagination-item" },
|
|
128
|
+
react_1.default.createElement("button", { type: "button", onClick: (e) => onPaginatonButtonClick(e, downshift), className: "pf-c-button pf-m-link pf-m-block", disabled: props.isLoadingList },
|
|
129
|
+
react_1.default.createElement(react_i18next_1.Trans, null, props.paginationBtnText))),
|
|
130
|
+
]);
|
|
163
131
|
return listToRender;
|
|
164
132
|
};
|
|
165
133
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
134
|
+
const selectedItem = react_1.useMemo(() => props.selectedItem, [(_c = (_b = (_a = props.selectedItem) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : props.selectedItem) !== null && _c !== void 0 ? _c : '']);
|
|
135
|
+
const newProps = Object.assign(Object.assign({}, props), { selectedItem, onChange: onChangeLocal, itemToString: dropdownUtils_1.itemToString,
|
|
136
|
+
renderListItems,
|
|
137
|
+
itemsList });
|
|
138
|
+
return props.searchable ? (react_1.default.createElement(SearchableList_1.default, Object.assign({}, newProps, { onInputChange: onInputChangeLocal }))) : (react_1.default.createElement(SelectList_1.default, Object.assign({}, newProps)));
|
|
169
139
|
}
|
|
170
140
|
exports.Dropdown = Dropdown;
|
|
171
141
|
Dropdown.defaultProps = defaultProps;
|
|
@@ -1,23 +1,12 @@
|
|
|
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
|
-
|
|
6
|
+
const utils_1 = require("@rh-support/utils");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
19
8
|
function DropdownWrapper(props) {
|
|
20
|
-
|
|
9
|
+
const onBlur = (event) => {
|
|
21
10
|
// on ios devices the onBlur event is called before the onClick event, so selecting an item in droponw
|
|
22
11
|
// closes the dropdown without selecting the item
|
|
23
12
|
// this is just a hack to prevent the downshift onBlur method from being called which closes the dropdown
|
|
@@ -25,12 +14,12 @@ function DropdownWrapper(props) {
|
|
|
25
14
|
event.nativeEvent.preventDownshiftDefault = true;
|
|
26
15
|
}
|
|
27
16
|
};
|
|
28
|
-
return (react_1.default.createElement("div", { id:
|
|
29
|
-
props.label && react_1.default.createElement("label",
|
|
17
|
+
return (react_1.default.createElement("div", { id: `${props.id}`, className: `downshift ${props.className} pf-c-select ${props.isOpen ? 'pf-m-expanded' : ''} `, "data-tracking-id": props['data-tracking-id'] ? props['data-tracking-id'] : null },
|
|
18
|
+
props.label && react_1.default.createElement("label", Object.assign({}, props.getLabelProps()), props.label),
|
|
30
19
|
props.toggleMenuComponent,
|
|
31
|
-
react_1.default.createElement("ul",
|
|
20
|
+
react_1.default.createElement("ul", Object.assign({}, props.getMenuProps({
|
|
32
21
|
onBlur: onBlur,
|
|
33
|
-
className:
|
|
22
|
+
className: `downshift-menu pf-c-select__menu ${props.hasTwoColumns ? 'column-selector-menu' : ''} ${props.isOpen ? 'open' : ''}`,
|
|
34
23
|
})), props.children)));
|
|
35
24
|
}
|
|
36
25
|
exports.default = DropdownWrapper;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MultiSelectDropDownList = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const DropDownList_1 = require("./DropDownList");
|
|
5
|
+
const withMulti_1 = require("./withMulti");
|
|
6
|
+
const MultiSelectDropDownList = withMulti_1.withMulti(DropDownList_1.Dropdown);
|
|
7
7
|
exports.MultiSelectDropDownList = MultiSelectDropDownList;
|