@carbon/ibm-products 2.28.1 → 2.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. package/css/index-full-carbon.css +1804 -233
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +40 -8
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +1804 -233
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +1785 -243
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/APIKeyModal/APIKeyModal.d.ts +2 -1
  18. package/es/components/APIKeyModal/APIKeyModal.js +13 -9
  19. package/es/components/APIKeyModal/APIKeyModal.types.d.ts +206 -0
  20. package/es/components/AboutModal/AboutModal.d.ts +73 -2
  21. package/es/components/AboutModal/AboutModal.js +16 -12
  22. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -0
  23. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.d.ts +1 -2
  24. package/es/components/Datagrid/useInitialColumnSort.d.ts +1 -0
  25. package/es/components/Datagrid/useInitialColumnSort.js +42 -0
  26. package/es/components/Datagrid/useSortableColumns.d.ts +4 -0
  27. package/es/components/Datagrid/useSortableColumns.js +16 -16
  28. package/es/components/Decorator/Decorator.d.ts +5 -0
  29. package/es/components/Decorator/Decorator.js +348 -0
  30. package/es/components/Decorator/DecoratorIcon.d.ts +5 -0
  31. package/es/components/Decorator/DecoratorIcon.js +95 -0
  32. package/es/components/Decorator/index.d.ts +1 -0
  33. package/es/components/Decorator/utils.d.ts +8 -0
  34. package/es/components/Decorator/utils.js +43 -0
  35. package/es/components/DescriptionList/DescriptionList.d.ts +42 -0
  36. package/es/components/DescriptionList/DescriptionList.js +88 -0
  37. package/es/components/DescriptionList/constants.d.ts +6 -0
  38. package/es/components/DescriptionList/constants.js +16 -0
  39. package/es/components/DescriptionList/index.d.ts +1 -0
  40. package/es/components/EmptyStates/EmptyStateContent.d.ts +1 -287
  41. package/es/components/HTTPErrors/HTTPErrorContent.d.ts +1 -293
  42. package/es/components/StatusIndicator/StatusIndicator.d.ts +5 -0
  43. package/es/components/StatusIndicator/StatusIndicator.js +100 -0
  44. package/es/components/StatusIndicator/StatusIndicatorStep.d.ts +5 -0
  45. package/es/components/StatusIndicator/index.d.ts +2 -0
  46. package/es/components/index.d.ts +3 -0
  47. package/es/global/js/package-settings.d.ts +4 -0
  48. package/es/global/js/package-settings.js +4 -0
  49. package/es/index.js +3 -0
  50. package/es/settings.d.ts +4 -0
  51. package/lib/components/APIKeyModal/APIKeyModal.d.ts +2 -1
  52. package/lib/components/APIKeyModal/APIKeyModal.js +13 -9
  53. package/lib/components/APIKeyModal/APIKeyModal.types.d.ts +206 -0
  54. package/lib/components/AboutModal/AboutModal.d.ts +73 -2
  55. package/lib/components/AboutModal/AboutModal.js +16 -12
  56. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -0
  57. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.d.ts +1 -2
  58. package/lib/components/Datagrid/useInitialColumnSort.d.ts +1 -0
  59. package/lib/components/Datagrid/useInitialColumnSort.js +46 -0
  60. package/lib/components/Datagrid/useSortableColumns.d.ts +4 -0
  61. package/lib/components/Datagrid/useSortableColumns.js +16 -15
  62. package/lib/components/Decorator/Decorator.d.ts +5 -0
  63. package/lib/components/Decorator/Decorator.js +355 -0
  64. package/lib/components/Decorator/DecoratorIcon.d.ts +5 -0
  65. package/lib/components/Decorator/DecoratorIcon.js +102 -0
  66. package/lib/components/Decorator/index.d.ts +1 -0
  67. package/lib/components/Decorator/utils.d.ts +8 -0
  68. package/lib/components/Decorator/utils.js +48 -0
  69. package/lib/components/DescriptionList/DescriptionList.d.ts +42 -0
  70. package/lib/components/DescriptionList/DescriptionList.js +95 -0
  71. package/lib/components/DescriptionList/constants.d.ts +6 -0
  72. package/lib/components/DescriptionList/constants.js +20 -0
  73. package/lib/components/DescriptionList/index.d.ts +1 -0
  74. package/lib/components/EmptyStates/EmptyStateContent.d.ts +1 -287
  75. package/lib/components/HTTPErrors/HTTPErrorContent.d.ts +1 -293
  76. package/lib/components/StatusIndicator/StatusIndicator.d.ts +5 -0
  77. package/lib/components/StatusIndicator/StatusIndicator.js +107 -0
  78. package/lib/components/StatusIndicator/StatusIndicatorStep.d.ts +5 -0
  79. package/lib/components/StatusIndicator/index.d.ts +2 -0
  80. package/lib/components/index.d.ts +3 -0
  81. package/lib/global/js/package-settings.d.ts +4 -0
  82. package/lib/global/js/package-settings.js +4 -0
  83. package/lib/index.js +15 -0
  84. package/lib/settings.d.ts +4 -0
  85. package/package.json +4 -4
  86. package/scss/components/Decorator/_carbon-imports.scss +9 -0
  87. package/scss/components/Decorator/_decorator.scss +400 -0
  88. package/scss/components/Decorator/_index-with-carbon.scss +9 -0
  89. package/scss/components/Decorator/_index.scss +8 -0
  90. package/scss/components/DescriptionList/_carbon-imports.scss +9 -0
  91. package/scss/components/DescriptionList/_description-list.scss +103 -0
  92. package/scss/components/DescriptionList/_index-with-carbon.scss +9 -0
  93. package/scss/components/DescriptionList/_index.scss +8 -0
  94. package/scss/components/SidePanel/_side-panel.scss +6 -1
  95. package/scss/components/StatusIndicator/_carbon-imports.scss +12 -0
  96. package/scss/components/StatusIndicator/_index-with-carbon.scss +9 -0
  97. package/scss/components/StatusIndicator/_index.scss +8 -0
  98. package/scss/components/StatusIndicator/_status-indicator.scss +93 -0
  99. package/scss/components/Tearsheet/_tearsheet.scss +41 -15
  100. package/scss/components/_index-with-carbon.scss +3 -0
  101. package/scss/components/_index.scss +3 -0
@@ -1,2 +1,3 @@
1
- export let APIKeyModal: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
2
1
  import React from 'react';
2
+ import { APIKeyModalProps } from './APIKeyModal.types';
3
+ export declare let APIKeyModal: React.FC<APIKeyModalProps>;
@@ -25,9 +25,10 @@ var componentName = 'APIKeyModal';
25
25
  // Default values for props
26
26
  var defaults = {
27
27
  apiKeyName: '',
28
- customSteps: Object.freeze([])
28
+ customSteps: []
29
29
  };
30
30
  var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
31
+ var _customSteps$currentS3;
31
32
  var apiKey = _ref.apiKey,
32
33
  apiKeyLabel = _ref.apiKeyLabel,
33
34
  _ref$apiKeyName = _ref.apiKeyName,
@@ -117,8 +118,9 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
117
118
  if (loading) {
118
119
  return true;
119
120
  }
120
- if (hasSteps && 'valid' in customSteps[currentStep]) {
121
- return !customSteps[currentStep].valid;
121
+ if (hasSteps && 'valid' in ((customSteps === null || customSteps === void 0 ? void 0 : customSteps[currentStep]) || [])) {
122
+ var _customSteps$currentS;
123
+ return !((_customSteps$currentS = customSteps[currentStep]) !== null && _customSteps$currentS !== void 0 && _customSteps$currentS.valid);
122
124
  }
123
125
  if (!hasSteps && nameRequired && !name) {
124
126
  return true;
@@ -149,7 +151,8 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
149
151
  } else if (apiKeyLoaded) {
150
152
  setTitle(generateSuccessTitle);
151
153
  } else if (hasSteps) {
152
- setTitle(customSteps[currentStep].title);
154
+ var _customSteps$currentS2;
155
+ setTitle((_customSteps$currentS2 = customSteps[currentStep]) === null || _customSteps$currentS2 === void 0 ? void 0 : _customSteps$currentS2.title);
153
156
  } else {
154
157
  setTitle(generateTitle);
155
158
  }
@@ -160,7 +163,7 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
160
163
  var onCloseHandler = function onCloseHandler() {
161
164
  setName('');
162
165
  setCurrentStep(0);
163
- onClose();
166
+ onClose === null || onClose === void 0 || onClose();
164
167
  };
165
168
  var submitHandler = /*#__PURE__*/function () {
166
169
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
@@ -204,9 +207,9 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
204
207
  break;
205
208
  case 21:
206
209
  if (editing) {
207
- onRequestEdit(name);
210
+ onRequestEdit === null || onRequestEdit === void 0 || onRequestEdit(name);
208
211
  } else {
209
- onRequestGenerate(name);
212
+ onRequestGenerate === null || onRequestGenerate === void 0 || onRequestGenerate(name);
210
213
  }
211
214
  case 22:
212
215
  case "end":
@@ -240,7 +243,7 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
240
243
  label: modalLabel
241
244
  }), /*#__PURE__*/React__default.createElement(ModalBody, {
242
245
  className: "".concat(blockClass, "__body-container")
243
- }, hasSteps && !apiKeyLoaded ? customSteps[currentStep].content : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, body && /*#__PURE__*/React__default.createElement("p", {
246
+ }, hasSteps && !apiKeyLoaded ? (_customSteps$currentS3 = customSteps[currentStep]) === null || _customSteps$currentS3 === void 0 ? void 0 : _customSteps$currentS3.content : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, body && /*#__PURE__*/React__default.createElement("p", {
244
247
  className: "".concat(blockClass, "__body")
245
248
  }, body), !editing && apiKey && hasAPIKeyVisibilityToggle && /*#__PURE__*/React__default.createElement(PasswordInput, {
246
249
  value: apiKey,
@@ -255,7 +258,7 @@ var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
255
258
  id: apiKeyInputId.current
256
259
  }), (editing || !apiKeyLoaded && nameRequired) && /*#__PURE__*/React__default.createElement(Form, {
257
260
  onSubmit: submitHandler,
258
- "aria-label": title
261
+ "aria-label": title !== null && title !== void 0 ? title : undefined
259
262
  }, /*#__PURE__*/React__default.createElement(TextInput, {
260
263
  helperText: nameHelperText,
261
264
  placeholder: namePlaceholder,
@@ -363,6 +366,7 @@ APIKeyModal.propTypes = {
363
366
  /**
364
367
  * if you need more options for key creation beyond just the name use custom steps to obtain whatever data is required.
365
368
  */
369
+ /**@ts-ignore*/
366
370
  customSteps: PropTypes.arrayOf(PropTypes.shape({
367
371
  /**
368
372
  * designates if the step has passed whatever validation rules are in place.
@@ -0,0 +1,206 @@
1
+ import { ReactNode } from 'react';
2
+ interface APIKeyModalCommonProps {
3
+ /**
4
+ * the api key that's displayed to the user when a request to create is fulfilled.
5
+ */
6
+ apiKey?: string;
7
+ /**
8
+ * label for the text input that holds the api key.
9
+ */
10
+ apiKeyLabel?: string;
11
+ /**
12
+ * the name of the api key. should only be supplied in edit mode.
13
+ */
14
+ apiKeyName?: string;
15
+ /**
16
+ * body content for the modal
17
+ */
18
+ body?: string;
19
+ /**
20
+ * optional class name
21
+ */
22
+ className?: string;
23
+ /**
24
+ * text for the close button
25
+ */
26
+ closeButtonText?: string;
27
+ /**
28
+ * text for the copy button
29
+ */
30
+ copyButtonText?: string;
31
+ /**
32
+ * Error message for when the copy function fails
33
+ */
34
+ copyErrorText?: string;
35
+ /**
36
+ * text description for the copy button icon
37
+ */
38
+ copyIconDescription?: string;
39
+ /**
40
+ * if you need more options for key creation beyond just the name use custom steps to obtain whatever data is required.
41
+ */
42
+ customSteps?: Array<{
43
+ valid?: boolean;
44
+ content?: ReactNode;
45
+ title?: string;
46
+ }>;
47
+ /**
48
+ * designates if the modal is in the edit mode
49
+ */
50
+ editing?: boolean;
51
+ /**
52
+ * designates if an error has occurred in a request
53
+ */
54
+ error?: boolean;
55
+ /**
56
+ * text to display if an error has occurred
57
+ */
58
+ errorText?: string;
59
+ /**
60
+ * default primary button text for modal in assumed default mode create or generate.
61
+ * in create mode this is the button text prior to supplying an api key, which then
62
+ * uses copyButtonText
63
+ */
64
+ generateButtonText?: string;
65
+ /**
66
+ * content to display if generate request was successful
67
+ */
68
+ generateSuccessBody?: ReactNode;
69
+ /**
70
+ * title for a successful key generation
71
+ */
72
+ generateSuccessTitle?: string;
73
+ /**
74
+ * default title for the modal in generate key mode
75
+ */
76
+ generateTitle?: string;
77
+ /**
78
+ * designates if the api input has the visibility toggle enabled
79
+ */
80
+ hasAPIKeyVisibilityToggle?: boolean;
81
+ /**
82
+ * designates if user is able to download the api key
83
+ */
84
+ hasDownloadLink?: boolean;
85
+ /**
86
+ * label text that's displayed when hovering over visibility toggler to hide key
87
+ */
88
+ hideAPIKeyLabel?: string;
89
+ /**
90
+ * designates if the modal is in a loading state via a request or some other in progress operation
91
+ */
92
+ loading?: boolean;
93
+ /**
94
+ * text that displays while modal is in the loading state
95
+ */
96
+ loadingText?: string;
97
+ /**
98
+ * general label text for modal
99
+ */
100
+ modalLabel?: string;
101
+ /**
102
+ * helper text for name input
103
+ */
104
+ nameHelperText?: string;
105
+ /**
106
+ * label for api key name input
107
+ */
108
+ nameLabel?: string;
109
+ /**
110
+ * placeholder text for api key name input
111
+ */
112
+ namePlaceholder?: string;
113
+ /**
114
+ * designates if a name is required or not for key generation. NOTE- if using custom steps set this to false since you will be using your own validation
115
+ */
116
+ nameRequired?: boolean;
117
+ /**
118
+ * handler for on modal close
119
+ */
120
+ onClose?(): void;
121
+ /**
122
+ * Optional callback if you want to use your own copy function instead of the build in one
123
+ * onCopy(apiKey)
124
+ */
125
+ onCopy?(apiKey: string): void;
126
+ /**
127
+ * handler for api key edit
128
+ */
129
+ onRequestEdit?(apiKeyName: string): void;
130
+ /**
131
+ * handler for api key generation
132
+ */
133
+ onRequestGenerate?(apiKeyName: string): void;
134
+ /**
135
+ * designates if modal is open or closed
136
+ */
137
+ open: boolean;
138
+ /**
139
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
140
+ */
141
+ portalTarget: ReactNode;
142
+ /**
143
+ * label text that's displayed when hovering over visibility toggler to show key
144
+ */
145
+ showAPIKeyLabel?: string;
146
+ }
147
+ type CustomStepConditionalProps = {
148
+ /**
149
+ * if you need more options for key creation beyond just the name use custom steps to obtain whatever data is required.
150
+ */
151
+ customSteps?: Array<{
152
+ valid?: boolean;
153
+ content?: ReactNode;
154
+ title?: string;
155
+ }>;
156
+ /**
157
+ * text that displays in the secondary button when using custom steps to indicate to the user that there is a previous step
158
+ */
159
+ previousStepButtonText: string;
160
+ /**
161
+ * text that displays in the primary button when using custom steps to indicate to the user that there is a next step
162
+ */
163
+ nextStepButtonText: string;
164
+ };
165
+ type EditingConditionalProps = {
166
+ /**
167
+ * designates if the modal is in the edit mode
168
+ */
169
+ editing?: boolean;
170
+ /**
171
+ * text for the edit button
172
+ */
173
+ editButtonText: string;
174
+ /**
175
+ * designates if the edit request was successful
176
+ */
177
+ editSuccess: boolean;
178
+ /**
179
+ * title for a successful edit
180
+ */
181
+ editSuccessTitle: string;
182
+ };
183
+ type HasDownloadLinkProps = {
184
+ /**
185
+ * designates if user is able to download the api key
186
+ */
187
+ hasDownloadLink?: boolean;
188
+ /**
189
+ * the content that appears that indicates the key is downloadable
190
+ */
191
+ downloadBodyText: string;
192
+ /**
193
+ * designates the name of downloadable json file with the key. if not specified will default to 'apikey'
194
+ */
195
+ downloadFileName: string;
196
+ /**
197
+ * designates the file type for the downloadable key
198
+ */
199
+ downloadFileType: 'txt' | 'json';
200
+ /**
201
+ * anchor text for the download link
202
+ */
203
+ downloadLinkText: string;
204
+ };
205
+ export type APIKeyModalProps = APIKeyModalCommonProps & CustomStepConditionalProps & EditingConditionalProps & HasDownloadLinkProps;
206
+ export {};
@@ -1,3 +1,74 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2021
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { ReactNode } from 'react';
8
+ interface AboutModalProps {
9
+ /**
10
+ * If you are legally required to display logos of technologies used
11
+ * to build your product you can provide this in the additionalInfo.
12
+ * Additional information will be displayed in the footer.
13
+ */
14
+ additionalInfo?: ReactNode;
15
+ /**
16
+ * Provide an optional class to be applied to the modal root node.
17
+ */
18
+ className?: string;
19
+ /**
20
+ * The accessibility title for the close icon.
21
+ */
22
+ closeIconDescription: string;
23
+ /**
24
+ * Subhead text providing any relevant product disclaimers including
25
+ * legal information (optional)
26
+ */
27
+ content?: ReactNode;
28
+ /**
29
+ * Trademark and copyright information. Displays first year of
30
+ * product release to current year.
31
+ */
32
+ copyrightText: string;
33
+ /**
34
+ * An array of Carbon `Link` component if there are additional information
35
+ * to call out within the card. The about modal should be used to display
36
+ * the product information and not where users go to find help (optional)
37
+ */
38
+ links?: ReactNode[];
39
+ /**
40
+ * A visual symbol used to represent the product.
41
+ */
42
+ logo: ReactNode;
43
+ /**
44
+ * Specifies aria label for AboutModal
45
+ */
46
+ modalAriaLabel?: string;
47
+ /**
48
+ * Specifies an optional handler which is called when the AboutModal
49
+ * is closed. Returning `false` prevents the AboutModal from closing.
50
+ */
51
+ onClose?: () => void | boolean;
52
+ /**
53
+ * Specifies whether the AboutModal is open or not.
54
+ */
55
+ open?: boolean;
56
+ /**
57
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
58
+ */
59
+ portalTarget?: ReactNode;
60
+ /**
61
+ * Header text that provides the product name. The IBM Services logo
62
+ * consists of two discrete, but required, elements: the iconic
63
+ * IBM 8-bar logo represented alongside the IBM Services logotype.
64
+ * Please follow these guidelines to ensure proper execution.
65
+ */
66
+ title: ReactNode;
67
+ /**
68
+ * Text that provides information on the version number of your product.
69
+ */
70
+ version: string;
71
+ }
1
72
  /**
2
73
  * The `AboutModal` component provides a way to communicate product information
3
74
  * to users. It is triggered by a user’s action, appears on top of the main
@@ -5,5 +76,5 @@
5
76
  * should be immediately apparent to the user, with a clear and obvious path
6
77
  * to completion.
7
78
  */
8
- export let AboutModal: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
9
- import React from 'react';
79
+ export declare let AboutModal: React.ForwardRefExoticComponent<AboutModalProps & React.RefAttributes<HTMLDivElement>>;
80
+ export {};
@@ -6,22 +6,21 @@
6
6
  */
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import { ComposedModal, ModalHeader, ModalBody, Theme, ModalFooter } from '@carbon/react';
9
10
  import React__default, { useState, useRef, useEffect } from 'react';
10
- import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
11
11
  import PropTypes from '../../node_modules/prop-types/index.js';
12
12
  import cx from 'classnames';
13
- import { pkg } from '../../settings.js';
14
- import uuidv4 from '../../global/js/utils/uuidv4.js';
15
13
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
16
- import { ComposedModal, ModalHeader, ModalBody, Theme, ModalFooter } from '@carbon/react';
14
+ import { pkg } from '../../settings.js';
17
15
  import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
16
+ import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
17
+ import uuidv4 from '../../global/js/utils/uuidv4.js';
18
18
 
19
19
  var _excluded = ["additionalInfo", "className", "closeIconDescription", "copyrightText", "content", "links", "logo", "modalAriaLabel", "onClose", "open", "portalTarget", "title", "version"];
20
20
 
21
21
  // The block part of our conventional BEM class names (blockClass__E--M).
22
22
  var blockClass = "".concat(pkg.prefix, "--about-modal");
23
23
  var componentName = 'AboutModal';
24
-
25
24
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
26
25
 
27
26
  /**
@@ -50,22 +49,27 @@ var AboutModal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
50
49
  _useState2 = _slicedToArray(_useState, 2),
51
50
  hasScrollingContent = _useState2[0],
52
51
  setHasScrollingContent = _useState2[1];
53
- var bodyRef = useRef();
54
- var contentRef = useRef();
52
+ var bodyRef = useRef(null);
53
+ var contentRef = useRef(null);
55
54
  var contentId = uuidv4();
56
55
  var renderPortalUse = usePortalTarget(portalTargetIn);
57
56
  var handleResize = function handleResize() {
57
+ var _bodyRef$current, _bodyRef$current2, _bodyRef$current3, _bodyRef$current4;
58
+ if (!((_bodyRef$current = bodyRef.current) !== null && _bodyRef$current !== void 0 && _bodyRef$current.clientHeight)) {
59
+ return;
60
+ }
58
61
  setHasScrollingContent(
59
62
  // if our scroll height exceeds the client height enable scrolling
60
- bodyRef.current.clientHeight < (hasScrollingContent ?
63
+ ((_bodyRef$current2 = bodyRef.current) === null || _bodyRef$current2 === void 0 ? void 0 : _bodyRef$current2.clientHeight) < (hasScrollingContent ?
61
64
  // Carbon modal adds 32px bottom margin when scrolling content is enabled
62
- bodyRef.current.scrollHeight - 32 : bodyRef.current.scrollHeight));
65
+ ((_bodyRef$current3 = bodyRef.current) === null || _bodyRef$current3 === void 0 ? void 0 : _bodyRef$current3.scrollHeight) - 32 : (_bodyRef$current4 = bodyRef.current) === null || _bodyRef$current4 === void 0 ? void 0 : _bodyRef$current4.scrollHeight));
63
66
  };
64
67
 
65
68
  // We can't add a ref directly to the ModalBody, so track it in a ref
66
69
  // as the parent of the current bodyRef element
67
70
  useEffect(function () {
68
- bodyRef.current = contentRef.current.parentElement;
71
+ var _contentRef$current;
72
+ bodyRef.current = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.parentElement;
69
73
  }, [bodyRef]);
70
74
 
71
75
  // Detect resize of the ModalBody to recalculate whether scrolling is enabled
@@ -89,8 +93,8 @@ var AboutModal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
89
93
  label: title,
90
94
  labelClassName: "".concat(blockClass, "__title")
91
95
  }), /*#__PURE__*/React__default.createElement(ModalBody, {
92
- "aria-label": hasScrollingContent ? '' : null,
93
- "aria-labelledby": hasScrollingContent ? contentId : null,
96
+ "aria-label": hasScrollingContent ? '' : undefined,
97
+ "aria-labelledby": hasScrollingContent ? contentId : undefined,
94
98
  className: "".concat(blockClass, "__body"),
95
99
  hasScrollingContent: hasScrollingContent
96
100
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -15,6 +15,7 @@ import { pkg } from '../../../settings.js';
15
15
  import { handleColumnResizeEndEvent, handleColumnResizingEvent } from './addons/stateReducer.js';
16
16
  import { getNodeTextContent } from '../../../global/js/utils/getNodeTextContent.js';
17
17
  import { DatagridSlug } from './addons/Slug/DatagridSlug.js';
18
+ import { useInitialColumnSort } from '../useInitialColumnSort.js';
18
19
 
19
20
  var _th;
20
21
  var _excluded = ["role"],
@@ -92,6 +93,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
92
93
  isTableSortable = datagridState.isTableSortable,
93
94
  rows = datagridState.rows,
94
95
  isFetching = datagridState.isFetching;
96
+ useInitialColumnSort(datagridState);
95
97
  // Used to measure the height of the table and uses that value
96
98
  // to display a vertical line to indicate the column you are resizing
97
99
  useEffect(function () {
@@ -6,7 +6,7 @@ declare function RowSizeDropdown({ align, legendText, ...props }: {
6
6
  }): import("react/jsx-runtime").JSX.Element;
7
7
  declare namespace RowSizeDropdown {
8
8
  namespace propTypes {
9
- let align: React.Validator<"left" | "right" | "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | null | undefined> | undefined;
9
+ let align: any;
10
10
  let datagridName: PropTypes.Requireable<string>;
11
11
  let legendText: PropTypes.Requireable<string>;
12
12
  let light: PropTypes.Requireable<boolean>;
@@ -14,5 +14,4 @@ declare namespace RowSizeDropdown {
14
14
  let selectedOption: PropTypes.Requireable<string>;
15
15
  }
16
16
  }
17
- import React from 'react';
18
17
  import PropTypes from 'prop-types';
@@ -0,0 +1 @@
1
+ export function useInitialColumnSort(instance: any): void;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import { useState, useEffect } from 'react';
10
+ import { getNewSortOrder } from './useSortableColumns.js';
11
+
12
+ var useInitialColumnSort = function useInitialColumnSort(instance) {
13
+ var _useState = useState(false),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ hasInitialSort = _useState2[0],
16
+ setHasInitialSort = _useState2[1];
17
+ useEffect(function () {
18
+ var initialState = instance.initialState,
19
+ headers = instance.headers,
20
+ onSort = instance.onSort,
21
+ isTableSortable = instance.isTableSortable;
22
+ var sortableColumn = initialState.sortableColumn;
23
+ var foundSortedCol = headers.some(function (h) {
24
+ return h.isSorted;
25
+ });
26
+ if (foundSortedCol || hasInitialSort || !isTableSortable) {
27
+ return;
28
+ }
29
+ if (sortableColumn) {
30
+ var columnId = sortableColumn.id,
31
+ order = sortableColumn.order;
32
+ var _getNewSortOrder = getNewSortOrder(order),
33
+ newSortDesc = _getNewSortOrder.newSortDesc,
34
+ newOrder = _getNewSortOrder.newOrder;
35
+ onSort === null || onSort === void 0 || onSort(columnId, newOrder);
36
+ instance.toggleSortBy(columnId, newSortDesc, false);
37
+ setHasInitialSort(true);
38
+ }
39
+ }, [instance, hasInitialSort]);
40
+ };
41
+
42
+ export { useInitialColumnSort };
@@ -1,2 +1,6 @@
1
+ export function getNewSortOrder(sortOrder: any): {
2
+ newSortDesc: undefined;
3
+ newOrder: string;
4
+ };
1
5
  export default useSortableColumns;
2
6
  declare function useSortableColumns(hooks: any): void;
@@ -20,6 +20,21 @@ var ordering = {
20
20
  DESC: 'DESC',
21
21
  NONE: 'NONE'
22
22
  };
23
+ var getNewSortOrder = function getNewSortOrder(sortOrder) {
24
+ var order = {
25
+ newSortDesc: undefined,
26
+ newOrder: ordering.NONE
27
+ };
28
+ if (sortOrder === false || sortOrder === ordering.DESC) {
29
+ order.newOrder = ordering.DESC;
30
+ order.newSortDesc = true;
31
+ }
32
+ if (sortOrder === undefined || sortOrder === ordering.ASC) {
33
+ order.newOrder = ordering.ASC;
34
+ order.newSortDesc = false;
35
+ }
36
+ return order;
37
+ };
23
38
  var getAriaSortValue = function getAriaSortValue(col, _ref) {
24
39
  var ascendingSortableLabelText = _ref.ascendingSortableLabelText,
25
40
  descendingSortableLabelText = _ref.descendingSortableLabelText,
@@ -128,24 +143,9 @@ var useSortableColumns = function useSortableColumns(hooks) {
128
143
  isTableSortable: true
129
144
  });
130
145
  };
131
- var getNewSortOrder = function getNewSortOrder(sortOrder) {
132
- var order = {
133
- newSortDesc: undefined,
134
- newOrder: ordering.NONE
135
- };
136
- if (sortOrder === false) {
137
- order.newOrder = ordering.DESC;
138
- order.newSortDesc = true;
139
- }
140
- if (sortOrder === undefined) {
141
- order.newOrder = ordering.ASC;
142
- order.newSortDesc = false;
143
- }
144
- return order;
145
- };
146
146
  hooks.visibleColumns.push(sortableVisibleColumns);
147
147
  hooks.useInstance.push(sortInstanceProps);
148
148
  };
149
149
  var useSortableColumns$1 = useSortableColumns;
150
150
 
151
- export { useSortableColumns$1 as default };
151
+ export { useSortableColumns$1 as default, getNewSortOrder };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The Decorator groups a key/value pair to look and behave like a single UI element.
3
+ */
4
+ export let Decorator: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
+ import React from 'react';