@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
@@ -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 {};
@@ -10,15 +10,15 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var react = require('@carbon/react');
13
14
  var React = require('react');
14
- var useResizeObserver = require('../../global/js/hooks/useResizeObserver.js');
15
15
  var index = require('../../node_modules/prop-types/index.js');
16
16
  var cx = require('classnames');
17
- var settings = require('../../settings.js');
18
- var uuidv4 = require('../../global/js/utils/uuidv4.js');
19
17
  var devtools = require('../../global/js/utils/devtools.js');
20
- var react = require('@carbon/react');
18
+ var settings = require('../../settings.js');
21
19
  var usePortalTarget = require('../../global/js/hooks/usePortalTarget.js');
20
+ var useResizeObserver = require('../../global/js/hooks/useResizeObserver.js');
21
+ var uuidv4 = require('../../global/js/utils/uuidv4.js');
22
22
 
23
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
24
 
@@ -30,7 +30,6 @@ var _excluded = ["additionalInfo", "className", "closeIconDescription", "copyrig
30
30
  // The block part of our conventional BEM class names (blockClass__E--M).
31
31
  var blockClass = "".concat(settings.pkg.prefix, "--about-modal");
32
32
  var componentName = 'AboutModal';
33
-
34
33
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
35
34
 
36
35
  /**
@@ -59,22 +58,27 @@ exports.AboutModal = /*#__PURE__*/React__default["default"].forwardRef(function
59
58
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
60
59
  hasScrollingContent = _useState2[0],
61
60
  setHasScrollingContent = _useState2[1];
62
- var bodyRef = React.useRef();
63
- var contentRef = React.useRef();
61
+ var bodyRef = React.useRef(null);
62
+ var contentRef = React.useRef(null);
64
63
  var contentId = uuidv4["default"]();
65
64
  var renderPortalUse = usePortalTarget.usePortalTarget(portalTargetIn);
66
65
  var handleResize = function handleResize() {
66
+ var _bodyRef$current, _bodyRef$current2, _bodyRef$current3, _bodyRef$current4;
67
+ if (!((_bodyRef$current = bodyRef.current) !== null && _bodyRef$current !== void 0 && _bodyRef$current.clientHeight)) {
68
+ return;
69
+ }
67
70
  setHasScrollingContent(
68
71
  // if our scroll height exceeds the client height enable scrolling
69
- bodyRef.current.clientHeight < (hasScrollingContent ?
72
+ ((_bodyRef$current2 = bodyRef.current) === null || _bodyRef$current2 === void 0 ? void 0 : _bodyRef$current2.clientHeight) < (hasScrollingContent ?
70
73
  // Carbon modal adds 32px bottom margin when scrolling content is enabled
71
- bodyRef.current.scrollHeight - 32 : bodyRef.current.scrollHeight));
74
+ ((_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));
72
75
  };
73
76
 
74
77
  // We can't add a ref directly to the ModalBody, so track it in a ref
75
78
  // as the parent of the current bodyRef element
76
79
  React.useEffect(function () {
77
- bodyRef.current = contentRef.current.parentElement;
80
+ var _contentRef$current;
81
+ bodyRef.current = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.parentElement;
78
82
  }, [bodyRef]);
79
83
 
80
84
  // Detect resize of the ModalBody to recalculate whether scrolling is enabled
@@ -98,8 +102,8 @@ exports.AboutModal = /*#__PURE__*/React__default["default"].forwardRef(function
98
102
  label: title,
99
103
  labelClassName: "".concat(blockClass, "__title")
100
104
  }), /*#__PURE__*/React__default["default"].createElement(react.ModalBody, {
101
- "aria-label": hasScrollingContent ? '' : null,
102
- "aria-labelledby": hasScrollingContent ? contentId : null,
105
+ "aria-label": hasScrollingContent ? '' : undefined,
106
+ "aria-labelledby": hasScrollingContent ? contentId : undefined,
103
107
  className: "".concat(blockClass, "__body"),
104
108
  hasScrollingContent: hasScrollingContent
105
109
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -19,6 +19,7 @@ var settings = require('../../../settings.js');
19
19
  var stateReducer = require('./addons/stateReducer.js');
20
20
  var getNodeTextContent = require('../../../global/js/utils/getNodeTextContent.js');
21
21
  var DatagridSlug = require('./addons/Slug/DatagridSlug.js');
22
+ var useInitialColumnSort = require('../useInitialColumnSort.js');
22
23
 
23
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
25
 
@@ -101,6 +102,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
101
102
  isTableSortable = datagridState.isTableSortable,
102
103
  rows = datagridState.rows,
103
104
  isFetching = datagridState.isFetching;
105
+ useInitialColumnSort.useInitialColumnSort(datagridState);
104
106
  // Used to measure the height of the table and uses that value
105
107
  // to display a vertical line to indicate the column you are resizing
106
108
  React.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,46 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var React = require('react');
14
+ var useSortableColumns = require('./useSortableColumns.js');
15
+
16
+ var useInitialColumnSort = function useInitialColumnSort(instance) {
17
+ var _useState = React.useState(false),
18
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
19
+ hasInitialSort = _useState2[0],
20
+ setHasInitialSort = _useState2[1];
21
+ React.useEffect(function () {
22
+ var initialState = instance.initialState,
23
+ headers = instance.headers,
24
+ onSort = instance.onSort,
25
+ isTableSortable = instance.isTableSortable;
26
+ var sortableColumn = initialState.sortableColumn;
27
+ var foundSortedCol = headers.some(function (h) {
28
+ return h.isSorted;
29
+ });
30
+ if (foundSortedCol || hasInitialSort || !isTableSortable) {
31
+ return;
32
+ }
33
+ if (sortableColumn) {
34
+ var columnId = sortableColumn.id,
35
+ order = sortableColumn.order;
36
+ var _getNewSortOrder = useSortableColumns.getNewSortOrder(order),
37
+ newSortDesc = _getNewSortOrder.newSortDesc,
38
+ newOrder = _getNewSortOrder.newOrder;
39
+ onSort === null || onSort === void 0 || onSort(columnId, newOrder);
40
+ instance.toggleSortBy(columnId, newSortDesc, false);
41
+ setHasInitialSort(true);
42
+ }
43
+ }, [instance, hasInitialSort]);
44
+ };
45
+
46
+ exports.useInitialColumnSort = 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;
@@ -29,6 +29,21 @@ var ordering = {
29
29
  DESC: 'DESC',
30
30
  NONE: 'NONE'
31
31
  };
32
+ var getNewSortOrder = function getNewSortOrder(sortOrder) {
33
+ var order = {
34
+ newSortDesc: undefined,
35
+ newOrder: ordering.NONE
36
+ };
37
+ if (sortOrder === false || sortOrder === ordering.DESC) {
38
+ order.newOrder = ordering.DESC;
39
+ order.newSortDesc = true;
40
+ }
41
+ if (sortOrder === undefined || sortOrder === ordering.ASC) {
42
+ order.newOrder = ordering.ASC;
43
+ order.newSortDesc = false;
44
+ }
45
+ return order;
46
+ };
32
47
  var getAriaSortValue = function getAriaSortValue(col, _ref) {
33
48
  var ascendingSortableLabelText = _ref.ascendingSortableLabelText,
34
49
  descendingSortableLabelText = _ref.descendingSortableLabelText,
@@ -137,24 +152,10 @@ var useSortableColumns = function useSortableColumns(hooks) {
137
152
  isTableSortable: true
138
153
  });
139
154
  };
140
- var getNewSortOrder = function getNewSortOrder(sortOrder) {
141
- var order = {
142
- newSortDesc: undefined,
143
- newOrder: ordering.NONE
144
- };
145
- if (sortOrder === false) {
146
- order.newOrder = ordering.DESC;
147
- order.newSortDesc = true;
148
- }
149
- if (sortOrder === undefined) {
150
- order.newOrder = ordering.ASC;
151
- order.newSortDesc = false;
152
- }
153
- return order;
154
- };
155
155
  hooks.visibleColumns.push(sortableVisibleColumns);
156
156
  hooks.useInstance.push(sortInstanceProps);
157
157
  };
158
158
  var useSortableColumns$1 = useSortableColumns;
159
159
 
160
160
  exports["default"] = useSortableColumns$1;
161
+ exports.getNewSortOrder = 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';