@carbon/ibm-products 2.54.0-canary.59 → 2.54.0-canary.60
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/css/index-full-carbon.css +4 -0
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +4 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +4 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +4 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyDownloader.d.ts +1 -1
- package/es/components/APIKeyModal/APIKeyDownloader.js +1 -1
- package/es/components/APIKeyModal/APIKeyModal.d.ts +13 -0
- package/es/components/APIKeyModal/APIKeyModal.js +69 -25
- package/es/components/APIKeyModal/APIKeyModal.types.d.ts +16 -2
- package/lib/components/APIKeyModal/APIKeyDownloader.d.ts +1 -1
- package/lib/components/APIKeyModal/APIKeyDownloader.js +1 -1
- package/lib/components/APIKeyModal/APIKeyModal.d.ts +13 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +68 -22
- package/lib/components/APIKeyModal/APIKeyModal.types.d.ts +16 -2
- package/package.json +3 -3
- package/scss/components/APIKeyModal/_api-key-modal.scss +4 -0
@@ -5,12 +5,12 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends,
|
8
|
+
import { objectSpread2 as _objectSpread2, objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import React__default, { forwardRef, useState, useRef, useEffect } from 'react';
|
10
10
|
import PropTypes from '../../_virtual/index.js';
|
11
11
|
import cx from 'classnames';
|
12
12
|
import { unstable_FeatureFlags, ComposedModal, ModalHeader, ModalBody, PasswordInput, TextInput, Form, InlineLoading, ModalFooter, Button } from '@carbon/react';
|
13
|
-
import { ErrorFilled, InformationFilled, Copy } from '@carbon/react/icons';
|
13
|
+
import { ErrorFilled, InformationFilled, CheckmarkFilled, Copy } from '@carbon/react/icons';
|
14
14
|
import { APIKeyDownloader } from './APIKeyDownloader.js';
|
15
15
|
import { pkg } from '../../settings.js';
|
16
16
|
import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
|
@@ -21,7 +21,7 @@ import { useFocus, claimFocus } from '../../global/js/hooks/useFocus.js';
|
|
21
21
|
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
22
22
|
|
23
23
|
var _ErrorFilled, _InformationFilled;
|
24
|
-
var _excluded = ["apiKey", "apiKeyLabel", "apiKeyName", "body", "className", "closeButtonText", "copyButtonText", "copyErrorText", "copyIconDescription", "customSteps", "downloadBodyText", "downloadFileName", "downloadFileType", "downloadLinkText", "downloadLinkLabel", "editButtonText", "editSuccess", "editSuccessTitle", "editing", "error", "errorText", "generateButtonText", "generateSuccessBody", "generateSuccessTitle", "generateTitle", "hasAPIKeyVisibilityToggle", "hasDownloadLink", "hideAPIKeyLabel", "launcherButtonRef", "loading", "loadingText", "modalLabel", "nameHelperText", "nameLabel", "namePlaceholder", "nameRequired", "nextStepButtonText", "onClose", "onCopy", "onRequestEdit", "onRequestGenerate", "open", "portalTarget", "previousStepButtonText", "selectorPrimaryFocus", "showAPIKeyLabel"];
|
24
|
+
var _excluded = ["apiKey", "apiKeyLabel", "apiKeyName", "body", "className", "closeButtonText", "copyButtonText", "copyErrorText", "copyIconDescription", "customSteps", "downloadBodyText", "downloadFileName", "downloadFileType", "downloadLinkText", "downloadLinkLabel", "editButtonText", "editSuccess", "editSuccessTitle", "editSuccessMessage", "editing", "error", "errorText", "generateButtonText", "generateSuccessBody", "generateSuccessTitle", "generateSuccessMessage", "generateTitle", "hasAPIKeyVisibilityToggle", "hasDownloadLink", "hideAPIKeyLabel", "launcherButtonRef", "loading", "loadingText", "modalLabel", "nameHelperText", "nameLabel", "namePlaceholder", "nameRequired", "nextStepButtonText", "onClose", "onCopy", "onRequestEdit", "onRequestGenerate", "open", "portalTarget", "previousStepButtonText", "selectorPrimaryFocus", "showAPIKeyLabel", "helperText"];
|
25
25
|
var componentName = 'APIKeyModal';
|
26
26
|
|
27
27
|
// Default values for props
|
@@ -52,12 +52,14 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
52
52
|
editButtonText = _ref.editButtonText,
|
53
53
|
editSuccess = _ref.editSuccess,
|
54
54
|
editSuccessTitle = _ref.editSuccessTitle,
|
55
|
+
editSuccessMessage = _ref.editSuccessMessage,
|
55
56
|
editing = _ref.editing,
|
56
57
|
error = _ref.error,
|
57
58
|
errorText = _ref.errorText,
|
58
59
|
generateButtonText = _ref.generateButtonText,
|
59
60
|
generateSuccessBody = _ref.generateSuccessBody,
|
60
61
|
generateSuccessTitle = _ref.generateSuccessTitle,
|
62
|
+
generateSuccessMessage = _ref.generateSuccessMessage,
|
61
63
|
generateTitle = _ref.generateTitle,
|
62
64
|
hasAPIKeyVisibilityToggle = _ref.hasAPIKeyVisibilityToggle,
|
63
65
|
hasDownloadLink = _ref.hasDownloadLink,
|
@@ -80,23 +82,28 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
80
82
|
previousStepButtonText = _ref.previousStepButtonText,
|
81
83
|
selectorPrimaryFocus = _ref.selectorPrimaryFocus,
|
82
84
|
showAPIKeyLabel = _ref.showAPIKeyLabel,
|
85
|
+
helperText = _ref.helperText,
|
83
86
|
rest = _objectWithoutProperties(_ref, _excluded);
|
84
87
|
var _useState = useState(null),
|
85
88
|
_useState2 = _slicedToArray(_useState, 2),
|
86
89
|
title = _useState2[0],
|
87
90
|
setTitle = _useState2[1];
|
88
|
-
var _useState3 = useState(
|
91
|
+
var _useState3 = useState(null),
|
89
92
|
_useState4 = _slicedToArray(_useState3, 2),
|
90
|
-
|
91
|
-
|
92
|
-
var _useState5 = useState(
|
93
|
+
successMessage = _useState4[0],
|
94
|
+
setSuccessMessage = _useState4[1];
|
95
|
+
var _useState5 = useState(false),
|
93
96
|
_useState6 = _slicedToArray(_useState5, 2),
|
94
|
-
|
95
|
-
|
96
|
-
var _useState7 = useState(
|
97
|
+
copyError = _useState6[0],
|
98
|
+
setCopyError = _useState6[1];
|
99
|
+
var _useState7 = useState(apiKeyName),
|
97
100
|
_useState8 = _slicedToArray(_useState7, 2),
|
98
|
-
|
99
|
-
|
101
|
+
name = _useState8[0],
|
102
|
+
setName = _useState8[1];
|
103
|
+
var _useState9 = useState(0),
|
104
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
105
|
+
currentStep = _useState10[0],
|
106
|
+
setCurrentStep = _useState10[1];
|
100
107
|
var copyRef = useRef(undefined);
|
101
108
|
var apiKeyInputId = useRef(uuidv4());
|
102
109
|
var nameInputId = useRef(uuidv4());
|
@@ -116,6 +123,7 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
116
123
|
};
|
117
124
|
var blockClass = "".concat(pkg.prefix, "--apikey-modal");
|
118
125
|
var localRef = useRef(undefined);
|
126
|
+
var PasswordInputRef = useRef(null);
|
119
127
|
var modalRef = ref || localRef;
|
120
128
|
var _useFocus = useFocus(modalRef, selectorPrimaryFocus),
|
121
129
|
firstElement = _useFocus.firstElement,
|
@@ -125,6 +133,9 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
125
133
|
if (copyRef.current && open && apiKeyLoaded) {
|
126
134
|
copyRef.current.focus();
|
127
135
|
}
|
136
|
+
if (PasswordInputRef !== null && PasswordInputRef !== void 0 && PasswordInputRef.current) {
|
137
|
+
PasswordInputRef === null || PasswordInputRef === void 0 || PasswordInputRef.current.setAttribute('readOnly', 'true');
|
138
|
+
}
|
128
139
|
}, [open, apiKeyLoaded]);
|
129
140
|
useEffect(function () {
|
130
141
|
if (open) {
|
@@ -172,16 +183,18 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
172
183
|
};
|
173
184
|
useEffect(function () {
|
174
185
|
if (editing && editSuccess) {
|
175
|
-
setTitle(
|
186
|
+
setTitle(generateTitle);
|
187
|
+
setSuccessMessage(editSuccessMessage !== null && editSuccessMessage !== void 0 ? editSuccessMessage : editSuccessTitle);
|
176
188
|
} else if (apiKeyLoaded) {
|
177
|
-
setTitle(
|
189
|
+
setTitle(generateTitle);
|
190
|
+
setSuccessMessage(generateSuccessMessage !== null && generateSuccessMessage !== void 0 ? generateSuccessMessage : generateSuccessTitle);
|
178
191
|
} else if (hasSteps) {
|
179
192
|
var _customSteps$currentS2;
|
180
193
|
setTitle((_customSteps$currentS2 = customSteps[currentStep]) === null || _customSteps$currentS2 === void 0 ? void 0 : _customSteps$currentS2.title);
|
181
194
|
} else {
|
182
195
|
setTitle(generateTitle);
|
183
196
|
}
|
184
|
-
}, [apiKeyLoaded, editing, editSuccess, editSuccessTitle, hasSteps, generateSuccessTitle, generateTitle, currentStep, customSteps]);
|
197
|
+
}, [apiKeyLoaded, loading, editing, editSuccess, editSuccessTitle, editSuccessMessage, hasSteps, generateSuccessTitle, generateSuccessMessage, generateTitle, currentStep, customSteps]);
|
185
198
|
var setNameHandler = function setNameHandler(evt) {
|
186
199
|
setName(evt.target.value);
|
187
200
|
};
|
@@ -279,7 +292,9 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
279
292
|
id: apiKeyInputId.current,
|
280
293
|
showPasswordLabel: showAPIKeyLabel,
|
281
294
|
hidePasswordLabel: hideAPIKeyLabel,
|
282
|
-
tooltipPosition: "left"
|
295
|
+
tooltipPosition: "left",
|
296
|
+
helperText: helperText,
|
297
|
+
ref: PasswordInputRef
|
283
298
|
}), !editing && apiKey && !hasAPIKeyVisibilityToggle && /*#__PURE__*/React__default.createElement(TextInput, {
|
284
299
|
value: apiKey,
|
285
300
|
labelText: apiKeyLabel,
|
@@ -307,7 +322,9 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
307
322
|
}, _ErrorFilled || (_ErrorFilled = /*#__PURE__*/React__default.createElement(ErrorFilled, {
|
308
323
|
size: 16
|
309
324
|
}))), /*#__PURE__*/React__default.createElement("p", {
|
310
|
-
className: "".concat(blockClass, "__messaging-text")
|
325
|
+
className: "".concat(blockClass, "__messaging-text"),
|
326
|
+
role: "alert",
|
327
|
+
"aria-live": "assertive"
|
311
328
|
}, copyError ? copyErrorText : errorText)), apiKeyLoaded && /*#__PURE__*/React__default.createElement("div", {
|
312
329
|
className: "".concat(blockClass, "__messaging")
|
313
330
|
}, _InformationFilled || (_InformationFilled = /*#__PURE__*/React__default.createElement(InformationFilled, {
|
@@ -320,8 +337,19 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
320
337
|
fileType: downloadFileType,
|
321
338
|
downloadLinkLabel: downloadLinkLabel
|
322
339
|
}) : /*#__PURE__*/React__default.createElement("div", {
|
323
|
-
className: "".concat(blockClass, "__messaging-text")
|
324
|
-
|
340
|
+
className: "".concat(blockClass, "__messaging-text"),
|
341
|
+
role: "alert",
|
342
|
+
"aria-live": "assertive"
|
343
|
+
}, generateSuccessBody)), (editSuccess || apiKeyLoaded && successMessage) && /*#__PURE__*/React__default.createElement("div", {
|
344
|
+
className: "".concat(blockClass, "__messaging")
|
345
|
+
}, /*#__PURE__*/React__default.createElement(CheckmarkFilled, {
|
346
|
+
size: 16,
|
347
|
+
className: "".concat(blockClass, "__checkmark-icon")
|
348
|
+
}), /*#__PURE__*/React__default.createElement("p", {
|
349
|
+
className: "".concat(blockClass, "__messaging-text"),
|
350
|
+
role: "alert",
|
351
|
+
"aria-live": "assertive"
|
352
|
+
}, successMessage)))), /*#__PURE__*/React__default.createElement(ModalFooter, {
|
325
353
|
className: "".concat(blockClass, "__footer")
|
326
354
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
327
355
|
type: "button",
|
@@ -355,7 +383,19 @@ var downloadRequiredProps = function downloadRequiredProps(type) {
|
|
355
383
|
|
356
384
|
// Return a placeholder if not released and not enabled by feature flag
|
357
385
|
APIKeyModal = pkg.checkComponentEnabled(APIKeyModal, componentName);
|
358
|
-
|
386
|
+
var deprecatedProps = {
|
387
|
+
/**
|
388
|
+
* deprecated
|
389
|
+
* title for a successful edit
|
390
|
+
*/
|
391
|
+
editSuccessTitle: PropTypes.string,
|
392
|
+
/**
|
393
|
+
* deprecated
|
394
|
+
* title for a successful key generation
|
395
|
+
*/
|
396
|
+
generateSuccessTitle: PropTypes.string
|
397
|
+
};
|
398
|
+
APIKeyModal.propTypes = _objectSpread2({
|
359
399
|
/**
|
360
400
|
* the api key that's displayed to the user when a request to create is fulfilled.
|
361
401
|
*/
|
@@ -413,7 +453,7 @@ APIKeyModal.propTypes = {
|
|
413
453
|
/**
|
414
454
|
* the content that appears that indicates the key is downloadable
|
415
455
|
*/
|
416
|
-
downloadBodyText:
|
456
|
+
downloadBodyText: PropTypes.string,
|
417
457
|
/**
|
418
458
|
* designates the name of downloadable json file with the key. if not specified will default to 'apikey'
|
419
459
|
*/
|
@@ -441,7 +481,7 @@ APIKeyModal.propTypes = {
|
|
441
481
|
/**
|
442
482
|
* title for a successful edit
|
443
483
|
*/
|
444
|
-
|
484
|
+
editSuccessMessage: editRequiredProps(PropTypes.string),
|
445
485
|
/**
|
446
486
|
* designates if the modal is in the edit mode
|
447
487
|
*/
|
@@ -467,7 +507,7 @@ APIKeyModal.propTypes = {
|
|
467
507
|
/**
|
468
508
|
* title for a successful key generation
|
469
509
|
*/
|
470
|
-
|
510
|
+
generateSuccessMessage: PropTypes.string,
|
471
511
|
/**
|
472
512
|
* default title for the modal in generate key mode
|
473
513
|
*/
|
@@ -480,6 +520,10 @@ APIKeyModal.propTypes = {
|
|
480
520
|
* designates if user is able to download the api key
|
481
521
|
*/
|
482
522
|
hasDownloadLink: PropTypes.bool,
|
523
|
+
/**
|
524
|
+
* helper text for password input
|
525
|
+
*/
|
526
|
+
helperText: PropTypes.string,
|
483
527
|
/**
|
484
528
|
* label text that's displayed when hovering over visibility toggler to hide key
|
485
529
|
*/
|
@@ -559,7 +603,7 @@ APIKeyModal.propTypes = {
|
|
559
603
|
* label text that's displayed when hovering over visibility toggler to show key
|
560
604
|
*/
|
561
605
|
showAPIKeyLabel: PropTypes.string
|
562
|
-
};
|
606
|
+
}, deprecatedProps);
|
563
607
|
APIKeyModal.displayName = componentName;
|
564
608
|
|
565
|
-
export { APIKeyModal };
|
609
|
+
export { APIKeyModal, deprecatedProps };
|
@@ -73,9 +73,14 @@ interface APIKeyModalCommonProps {
|
|
73
73
|
*/
|
74
74
|
generateSuccessBody?: ReactNode;
|
75
75
|
/**
|
76
|
+
* * @deprecated use `generateSuccessMessage` instead
|
76
77
|
* title for a successful key generation
|
77
78
|
*/
|
78
79
|
generateSuccessTitle?: string;
|
80
|
+
/**
|
81
|
+
* success message for a successful key generation
|
82
|
+
*/
|
83
|
+
generateSuccessMessage?: string;
|
79
84
|
/**
|
80
85
|
* default title for the modal in generate key mode
|
81
86
|
*/
|
@@ -158,6 +163,10 @@ interface APIKeyModalCommonProps {
|
|
158
163
|
* label text that's displayed when hovering over visibility toggler to show key
|
159
164
|
*/
|
160
165
|
showAPIKeyLabel?: string;
|
166
|
+
/**
|
167
|
+
* helper text for password input
|
168
|
+
*/
|
169
|
+
helperText?: string;
|
161
170
|
}
|
162
171
|
type CustomStepConditionalProps = {
|
163
172
|
/**
|
@@ -191,9 +200,14 @@ type EditingConditionalProps = {
|
|
191
200
|
*/
|
192
201
|
editSuccess: boolean;
|
193
202
|
/**
|
203
|
+
* * @deprecated use `editSuccessMessage` instead
|
194
204
|
* title for a successful edit
|
195
205
|
*/
|
196
|
-
editSuccessTitle
|
206
|
+
editSuccessTitle?: string;
|
207
|
+
/**
|
208
|
+
* success message for edit
|
209
|
+
*/
|
210
|
+
editSuccessMessage: string;
|
197
211
|
};
|
198
212
|
type HasDownloadLinkProps = {
|
199
213
|
/**
|
@@ -203,7 +217,7 @@ type HasDownloadLinkProps = {
|
|
203
217
|
/**
|
204
218
|
* the content that appears that indicates the key is downloadable
|
205
219
|
*/
|
206
|
-
downloadBodyText
|
220
|
+
downloadBodyText?: string;
|
207
221
|
/**
|
208
222
|
* designates the name of downloadable json file with the key. if not specified will default to 'apikey'
|
209
223
|
*/
|
@@ -10,7 +10,7 @@ export namespace APIKeyDownloader {
|
|
10
10
|
export { componentName as displayName };
|
11
11
|
export namespace propTypes {
|
12
12
|
let apiKey: PropTypes.Validator<string>;
|
13
|
-
let body: PropTypes.
|
13
|
+
let body: PropTypes.Requireable<string>;
|
14
14
|
let downloadLinkLabel: PropTypes.Requireable<string>;
|
15
15
|
let fileName: PropTypes.Validator<string>;
|
16
16
|
let fileType: PropTypes.Validator<string>;
|
@@ -1,3 +1,16 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
2
3
|
import { APIKeyModalProps } from './APIKeyModal.types';
|
3
4
|
export declare let APIKeyModal: React.FC<APIKeyModalProps>;
|
5
|
+
export declare const deprecatedProps: {
|
6
|
+
/**
|
7
|
+
* deprecated
|
8
|
+
* title for a successful edit
|
9
|
+
*/
|
10
|
+
editSuccessTitle: PropTypes.Requireable<string>;
|
11
|
+
/**
|
12
|
+
* deprecated
|
13
|
+
* title for a successful key generation
|
14
|
+
*/
|
15
|
+
generateSuccessTitle: PropTypes.Requireable<string>;
|
16
|
+
};
|
@@ -23,7 +23,7 @@ var useFocus = require('../../global/js/hooks/useFocus.js');
|
|
23
23
|
var usePreviousValue = require('../../global/js/hooks/usePreviousValue.js');
|
24
24
|
|
25
25
|
var _ErrorFilled, _InformationFilled;
|
26
|
-
var _excluded = ["apiKey", "apiKeyLabel", "apiKeyName", "body", "className", "closeButtonText", "copyButtonText", "copyErrorText", "copyIconDescription", "customSteps", "downloadBodyText", "downloadFileName", "downloadFileType", "downloadLinkText", "downloadLinkLabel", "editButtonText", "editSuccess", "editSuccessTitle", "editing", "error", "errorText", "generateButtonText", "generateSuccessBody", "generateSuccessTitle", "generateTitle", "hasAPIKeyVisibilityToggle", "hasDownloadLink", "hideAPIKeyLabel", "launcherButtonRef", "loading", "loadingText", "modalLabel", "nameHelperText", "nameLabel", "namePlaceholder", "nameRequired", "nextStepButtonText", "onClose", "onCopy", "onRequestEdit", "onRequestGenerate", "open", "portalTarget", "previousStepButtonText", "selectorPrimaryFocus", "showAPIKeyLabel"];
|
26
|
+
var _excluded = ["apiKey", "apiKeyLabel", "apiKeyName", "body", "className", "closeButtonText", "copyButtonText", "copyErrorText", "copyIconDescription", "customSteps", "downloadBodyText", "downloadFileName", "downloadFileType", "downloadLinkText", "downloadLinkLabel", "editButtonText", "editSuccess", "editSuccessTitle", "editSuccessMessage", "editing", "error", "errorText", "generateButtonText", "generateSuccessBody", "generateSuccessTitle", "generateSuccessMessage", "generateTitle", "hasAPIKeyVisibilityToggle", "hasDownloadLink", "hideAPIKeyLabel", "launcherButtonRef", "loading", "loadingText", "modalLabel", "nameHelperText", "nameLabel", "namePlaceholder", "nameRequired", "nextStepButtonText", "onClose", "onCopy", "onRequestEdit", "onRequestGenerate", "open", "portalTarget", "previousStepButtonText", "selectorPrimaryFocus", "showAPIKeyLabel", "helperText"];
|
27
27
|
var componentName = 'APIKeyModal';
|
28
28
|
|
29
29
|
// Default values for props
|
@@ -54,12 +54,14 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
54
54
|
editButtonText = _ref.editButtonText,
|
55
55
|
editSuccess = _ref.editSuccess,
|
56
56
|
editSuccessTitle = _ref.editSuccessTitle,
|
57
|
+
editSuccessMessage = _ref.editSuccessMessage,
|
57
58
|
editing = _ref.editing,
|
58
59
|
error = _ref.error,
|
59
60
|
errorText = _ref.errorText,
|
60
61
|
generateButtonText = _ref.generateButtonText,
|
61
62
|
generateSuccessBody = _ref.generateSuccessBody,
|
62
63
|
generateSuccessTitle = _ref.generateSuccessTitle,
|
64
|
+
generateSuccessMessage = _ref.generateSuccessMessage,
|
63
65
|
generateTitle = _ref.generateTitle,
|
64
66
|
hasAPIKeyVisibilityToggle = _ref.hasAPIKeyVisibilityToggle,
|
65
67
|
hasDownloadLink = _ref.hasDownloadLink,
|
@@ -82,23 +84,28 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
82
84
|
previousStepButtonText = _ref.previousStepButtonText,
|
83
85
|
selectorPrimaryFocus = _ref.selectorPrimaryFocus,
|
84
86
|
showAPIKeyLabel = _ref.showAPIKeyLabel,
|
87
|
+
helperText = _ref.helperText,
|
85
88
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
86
89
|
var _useState = React.useState(null),
|
87
90
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
88
91
|
title = _useState2[0],
|
89
92
|
setTitle = _useState2[1];
|
90
|
-
var _useState3 = React.useState(
|
93
|
+
var _useState3 = React.useState(null),
|
91
94
|
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
92
|
-
|
93
|
-
|
94
|
-
var _useState5 = React.useState(
|
95
|
+
successMessage = _useState4[0],
|
96
|
+
setSuccessMessage = _useState4[1];
|
97
|
+
var _useState5 = React.useState(false),
|
95
98
|
_useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
|
96
|
-
|
97
|
-
|
98
|
-
var _useState7 = React.useState(
|
99
|
+
copyError = _useState6[0],
|
100
|
+
setCopyError = _useState6[1];
|
101
|
+
var _useState7 = React.useState(apiKeyName),
|
99
102
|
_useState8 = _rollupPluginBabelHelpers.slicedToArray(_useState7, 2),
|
100
|
-
|
101
|
-
|
103
|
+
name = _useState8[0],
|
104
|
+
setName = _useState8[1];
|
105
|
+
var _useState9 = React.useState(0),
|
106
|
+
_useState10 = _rollupPluginBabelHelpers.slicedToArray(_useState9, 2),
|
107
|
+
currentStep = _useState10[0],
|
108
|
+
setCurrentStep = _useState10[1];
|
102
109
|
var copyRef = React.useRef(undefined);
|
103
110
|
var apiKeyInputId = React.useRef(uuidv4.default());
|
104
111
|
var nameInputId = React.useRef(uuidv4.default());
|
@@ -118,6 +125,7 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
118
125
|
};
|
119
126
|
var blockClass = "".concat(settings.pkg.prefix, "--apikey-modal");
|
120
127
|
var localRef = React.useRef(undefined);
|
128
|
+
var PasswordInputRef = React.useRef(null);
|
121
129
|
var modalRef = ref || localRef;
|
122
130
|
var _useFocus = useFocus.useFocus(modalRef, selectorPrimaryFocus),
|
123
131
|
firstElement = _useFocus.firstElement,
|
@@ -127,6 +135,9 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
127
135
|
if (copyRef.current && open && apiKeyLoaded) {
|
128
136
|
copyRef.current.focus();
|
129
137
|
}
|
138
|
+
if (PasswordInputRef !== null && PasswordInputRef !== void 0 && PasswordInputRef.current) {
|
139
|
+
PasswordInputRef === null || PasswordInputRef === void 0 || PasswordInputRef.current.setAttribute('readOnly', 'true');
|
140
|
+
}
|
130
141
|
}, [open, apiKeyLoaded]);
|
131
142
|
React.useEffect(function () {
|
132
143
|
if (open) {
|
@@ -174,16 +185,18 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
174
185
|
};
|
175
186
|
React.useEffect(function () {
|
176
187
|
if (editing && editSuccess) {
|
177
|
-
setTitle(
|
188
|
+
setTitle(generateTitle);
|
189
|
+
setSuccessMessage(editSuccessMessage !== null && editSuccessMessage !== void 0 ? editSuccessMessage : editSuccessTitle);
|
178
190
|
} else if (apiKeyLoaded) {
|
179
|
-
setTitle(
|
191
|
+
setTitle(generateTitle);
|
192
|
+
setSuccessMessage(generateSuccessMessage !== null && generateSuccessMessage !== void 0 ? generateSuccessMessage : generateSuccessTitle);
|
180
193
|
} else if (hasSteps) {
|
181
194
|
var _customSteps$currentS2;
|
182
195
|
setTitle((_customSteps$currentS2 = customSteps[currentStep]) === null || _customSteps$currentS2 === void 0 ? void 0 : _customSteps$currentS2.title);
|
183
196
|
} else {
|
184
197
|
setTitle(generateTitle);
|
185
198
|
}
|
186
|
-
}, [apiKeyLoaded, editing, editSuccess, editSuccessTitle, hasSteps, generateSuccessTitle, generateTitle, currentStep, customSteps]);
|
199
|
+
}, [apiKeyLoaded, loading, editing, editSuccess, editSuccessTitle, editSuccessMessage, hasSteps, generateSuccessTitle, generateSuccessMessage, generateTitle, currentStep, customSteps]);
|
187
200
|
var setNameHandler = function setNameHandler(evt) {
|
188
201
|
setName(evt.target.value);
|
189
202
|
};
|
@@ -281,7 +294,9 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
281
294
|
id: apiKeyInputId.current,
|
282
295
|
showPasswordLabel: showAPIKeyLabel,
|
283
296
|
hidePasswordLabel: hideAPIKeyLabel,
|
284
|
-
tooltipPosition: "left"
|
297
|
+
tooltipPosition: "left",
|
298
|
+
helperText: helperText,
|
299
|
+
ref: PasswordInputRef
|
285
300
|
}), !editing && apiKey && !hasAPIKeyVisibilityToggle && /*#__PURE__*/React.createElement(react.TextInput, {
|
286
301
|
value: apiKey,
|
287
302
|
labelText: apiKeyLabel,
|
@@ -309,7 +324,9 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
309
324
|
}, _ErrorFilled || (_ErrorFilled = /*#__PURE__*/React.createElement(icons.ErrorFilled, {
|
310
325
|
size: 16
|
311
326
|
}))), /*#__PURE__*/React.createElement("p", {
|
312
|
-
className: "".concat(blockClass, "__messaging-text")
|
327
|
+
className: "".concat(blockClass, "__messaging-text"),
|
328
|
+
role: "alert",
|
329
|
+
"aria-live": "assertive"
|
313
330
|
}, copyError ? copyErrorText : errorText)), apiKeyLoaded && /*#__PURE__*/React.createElement("div", {
|
314
331
|
className: "".concat(blockClass, "__messaging")
|
315
332
|
}, _InformationFilled || (_InformationFilled = /*#__PURE__*/React.createElement(icons.InformationFilled, {
|
@@ -322,8 +339,19 @@ exports.APIKeyModal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
322
339
|
fileType: downloadFileType,
|
323
340
|
downloadLinkLabel: downloadLinkLabel
|
324
341
|
}) : /*#__PURE__*/React.createElement("div", {
|
325
|
-
className: "".concat(blockClass, "__messaging-text")
|
326
|
-
|
342
|
+
className: "".concat(blockClass, "__messaging-text"),
|
343
|
+
role: "alert",
|
344
|
+
"aria-live": "assertive"
|
345
|
+
}, generateSuccessBody)), (editSuccess || apiKeyLoaded && successMessage) && /*#__PURE__*/React.createElement("div", {
|
346
|
+
className: "".concat(blockClass, "__messaging")
|
347
|
+
}, /*#__PURE__*/React.createElement(icons.CheckmarkFilled, {
|
348
|
+
size: 16,
|
349
|
+
className: "".concat(blockClass, "__checkmark-icon")
|
350
|
+
}), /*#__PURE__*/React.createElement("p", {
|
351
|
+
className: "".concat(blockClass, "__messaging-text"),
|
352
|
+
role: "alert",
|
353
|
+
"aria-live": "assertive"
|
354
|
+
}, successMessage)))), /*#__PURE__*/React.createElement(react.ModalFooter, {
|
327
355
|
className: "".concat(blockClass, "__footer")
|
328
356
|
}, /*#__PURE__*/React.createElement(react.Button, {
|
329
357
|
type: "button",
|
@@ -357,7 +385,19 @@ var downloadRequiredProps = function downloadRequiredProps(type) {
|
|
357
385
|
|
358
386
|
// Return a placeholder if not released and not enabled by feature flag
|
359
387
|
exports.APIKeyModal = settings.pkg.checkComponentEnabled(exports.APIKeyModal, componentName);
|
360
|
-
|
388
|
+
var deprecatedProps = {
|
389
|
+
/**
|
390
|
+
* deprecated
|
391
|
+
* title for a successful edit
|
392
|
+
*/
|
393
|
+
editSuccessTitle: index.default.string,
|
394
|
+
/**
|
395
|
+
* deprecated
|
396
|
+
* title for a successful key generation
|
397
|
+
*/
|
398
|
+
generateSuccessTitle: index.default.string
|
399
|
+
};
|
400
|
+
exports.APIKeyModal.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
361
401
|
/**
|
362
402
|
* the api key that's displayed to the user when a request to create is fulfilled.
|
363
403
|
*/
|
@@ -415,7 +455,7 @@ exports.APIKeyModal.propTypes = {
|
|
415
455
|
/**
|
416
456
|
* the content that appears that indicates the key is downloadable
|
417
457
|
*/
|
418
|
-
downloadBodyText:
|
458
|
+
downloadBodyText: index.default.string,
|
419
459
|
/**
|
420
460
|
* designates the name of downloadable json file with the key. if not specified will default to 'apikey'
|
421
461
|
*/
|
@@ -443,7 +483,7 @@ exports.APIKeyModal.propTypes = {
|
|
443
483
|
/**
|
444
484
|
* title for a successful edit
|
445
485
|
*/
|
446
|
-
|
486
|
+
editSuccessMessage: editRequiredProps(index.default.string),
|
447
487
|
/**
|
448
488
|
* designates if the modal is in the edit mode
|
449
489
|
*/
|
@@ -469,7 +509,7 @@ exports.APIKeyModal.propTypes = {
|
|
469
509
|
/**
|
470
510
|
* title for a successful key generation
|
471
511
|
*/
|
472
|
-
|
512
|
+
generateSuccessMessage: index.default.string,
|
473
513
|
/**
|
474
514
|
* default title for the modal in generate key mode
|
475
515
|
*/
|
@@ -482,6 +522,10 @@ exports.APIKeyModal.propTypes = {
|
|
482
522
|
* designates if user is able to download the api key
|
483
523
|
*/
|
484
524
|
hasDownloadLink: index.default.bool,
|
525
|
+
/**
|
526
|
+
* helper text for password input
|
527
|
+
*/
|
528
|
+
helperText: index.default.string,
|
485
529
|
/**
|
486
530
|
* label text that's displayed when hovering over visibility toggler to hide key
|
487
531
|
*/
|
@@ -561,5 +605,7 @@ exports.APIKeyModal.propTypes = {
|
|
561
605
|
* label text that's displayed when hovering over visibility toggler to show key
|
562
606
|
*/
|
563
607
|
showAPIKeyLabel: index.default.string
|
564
|
-
};
|
608
|
+
}, deprecatedProps);
|
565
609
|
exports.APIKeyModal.displayName = componentName;
|
610
|
+
|
611
|
+
exports.deprecatedProps = deprecatedProps;
|
@@ -73,9 +73,14 @@ interface APIKeyModalCommonProps {
|
|
73
73
|
*/
|
74
74
|
generateSuccessBody?: ReactNode;
|
75
75
|
/**
|
76
|
+
* * @deprecated use `generateSuccessMessage` instead
|
76
77
|
* title for a successful key generation
|
77
78
|
*/
|
78
79
|
generateSuccessTitle?: string;
|
80
|
+
/**
|
81
|
+
* success message for a successful key generation
|
82
|
+
*/
|
83
|
+
generateSuccessMessage?: string;
|
79
84
|
/**
|
80
85
|
* default title for the modal in generate key mode
|
81
86
|
*/
|
@@ -158,6 +163,10 @@ interface APIKeyModalCommonProps {
|
|
158
163
|
* label text that's displayed when hovering over visibility toggler to show key
|
159
164
|
*/
|
160
165
|
showAPIKeyLabel?: string;
|
166
|
+
/**
|
167
|
+
* helper text for password input
|
168
|
+
*/
|
169
|
+
helperText?: string;
|
161
170
|
}
|
162
171
|
type CustomStepConditionalProps = {
|
163
172
|
/**
|
@@ -191,9 +200,14 @@ type EditingConditionalProps = {
|
|
191
200
|
*/
|
192
201
|
editSuccess: boolean;
|
193
202
|
/**
|
203
|
+
* * @deprecated use `editSuccessMessage` instead
|
194
204
|
* title for a successful edit
|
195
205
|
*/
|
196
|
-
editSuccessTitle
|
206
|
+
editSuccessTitle?: string;
|
207
|
+
/**
|
208
|
+
* success message for edit
|
209
|
+
*/
|
210
|
+
editSuccessMessage: string;
|
197
211
|
};
|
198
212
|
type HasDownloadLinkProps = {
|
199
213
|
/**
|
@@ -203,7 +217,7 @@ type HasDownloadLinkProps = {
|
|
203
217
|
/**
|
204
218
|
* the content that appears that indicates the key is downloadable
|
205
219
|
*/
|
206
|
-
downloadBodyText
|
220
|
+
downloadBodyText?: string;
|
207
221
|
/**
|
208
222
|
* designates the name of downloadable json file with the key. if not specified will default to 'apikey'
|
209
223
|
*/
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.54.0-canary.
|
4
|
+
"version": "2.54.0-canary.60+bea9003e1",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.24.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.50.0-canary.
|
99
|
+
"@carbon/ibm-products-styles": "^2.50.0-canary.60+bea9003e1",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "bea9003e1c1dcf2f1c19ecaccd6a4096bc313d8d"
|
124
124
|
}
|