@carbon/ibm-products 2.25.0 → 2.27.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +556 -63
- 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 +50 -16
- 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 +556 -63
- 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 +527 -55
- 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/BigNumbers/BigNumbers.d.ts +11 -0
- package/es/components/BigNumbers/BigNumbers.js +238 -0
- package/es/components/BigNumbers/constants.d.ts +13 -0
- package/es/components/BigNumbers/constants.js +67 -0
- package/es/components/BigNumbers/index.d.ts +1 -0
- package/es/components/Cascade/Cascade.d.ts +19 -2
- package/es/components/Cascade/Cascade.js +12 -9
- package/es/components/Coachmark/CoachmarkTagline.js +1 -2
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
- package/es/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
- package/es/components/DataSpreadsheet/utils/checkForHoldingKey.js +17 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +9 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +21 -8
- package/es/components/Datagrid/Datagrid/DatagridRow.js +15 -2
- package/es/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +21 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +32 -9
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +35 -3
- package/es/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.d.ts +2 -0
- package/es/components/Datagrid/Datagrid/addons/Slug/{ColumnHeaderSlug.js → DatagridSlug.js} +4 -4
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +3 -3
- package/es/components/Datagrid/useSelectAllToggle.js +5 -3
- package/es/components/Datagrid/useSortableColumns.js +2 -2
- package/es/components/EmptyStates/EmptyStateContent.d.ts +1 -1
- package/es/components/FullPageError/FullPageError.js +41 -15
- package/es/components/FullPageError/assets/Error403SVG.d.ts +9 -0
- package/es/components/FullPageError/assets/Error403SVG.js +714 -0
- package/es/components/FullPageError/assets/Error404SVG.d.ts +9 -0
- package/es/components/FullPageError/assets/Error404SVG.js +623 -0
- package/es/components/HTTPErrors/HTTPErrorContent.d.ts +1 -1
- package/es/components/InterstitialScreen/InterstitialScreen.js +1 -1
- package/es/components/SidePanel/SidePanel.js +13 -6
- package/es/components/SidePanel/motion/variants.d.ts +39 -12
- package/es/components/SidePanel/motion/variants.js +42 -11
- package/es/components/StringFormatter/StringFormatter.d.ts +6 -0
- package/es/components/StringFormatter/StringFormatter.js +79 -0
- package/es/components/StringFormatter/index.d.ts +1 -0
- package/es/components/StringFormatter/utils/enums.d.ts +14 -0
- package/es/components/StringFormatter/utils/enums.js +23 -0
- package/es/components/Tearsheet/TearsheetShell.js +26 -8
- package/es/components/UserAvatar/UserAvatar.js +59 -44
- package/es/components/index.d.ts +2 -0
- package/es/global/js/hooks/index.d.ts +2 -0
- package/es/global/js/hooks/useFocus.d.ts +11 -0
- package/es/global/js/hooks/useFocus.js +76 -0
- package/es/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
- package/es/global/js/hooks/useIsomorphicEffect.js +14 -0
- package/es/global/js/package-settings.d.ts +2 -0
- package/es/global/js/package-settings.js +2 -0
- package/es/index.js +2 -0
- package/es/settings.d.ts +2 -0
- package/lib/components/BigNumbers/BigNumbers.d.ts +11 -0
- package/lib/components/BigNumbers/BigNumbers.js +244 -0
- package/lib/components/BigNumbers/constants.d.ts +13 -0
- package/lib/components/BigNumbers/constants.js +76 -0
- package/lib/components/BigNumbers/index.d.ts +1 -0
- package/lib/components/Cascade/Cascade.d.ts +19 -2
- package/lib/components/Cascade/Cascade.js +12 -9
- package/lib/components/Coachmark/CoachmarkTagline.js +3 -4
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
- package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
- package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.js +21 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +9 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +20 -7
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +14 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +20 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +30 -7
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +33 -1
- package/lib/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.d.ts +2 -0
- package/lib/components/Datagrid/Datagrid/addons/Slug/{ColumnHeaderSlug.js → DatagridSlug.js} +4 -4
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +3 -3
- package/lib/components/Datagrid/useSelectAllToggle.js +4 -2
- package/lib/components/Datagrid/useSortableColumns.js +2 -2
- package/lib/components/EmptyStates/EmptyStateContent.d.ts +1 -1
- package/lib/components/FullPageError/FullPageError.js +41 -15
- package/lib/components/FullPageError/assets/Error403SVG.d.ts +9 -0
- package/lib/components/FullPageError/assets/Error403SVG.js +722 -0
- package/lib/components/FullPageError/assets/Error404SVG.d.ts +9 -0
- package/lib/components/FullPageError/assets/Error404SVG.js +631 -0
- package/lib/components/HTTPErrors/HTTPErrorContent.d.ts +1 -1
- package/lib/components/InterstitialScreen/InterstitialScreen.js +3 -3
- package/lib/components/SidePanel/SidePanel.js +11 -4
- package/lib/components/SidePanel/motion/variants.d.ts +39 -12
- package/lib/components/SidePanel/motion/variants.js +42 -10
- package/lib/components/StringFormatter/StringFormatter.d.ts +6 -0
- package/lib/components/StringFormatter/StringFormatter.js +85 -0
- package/lib/components/StringFormatter/index.d.ts +1 -0
- package/lib/components/StringFormatter/utils/enums.d.ts +14 -0
- package/lib/components/StringFormatter/utils/enums.js +27 -0
- package/lib/components/Tearsheet/TearsheetShell.js +26 -8
- package/lib/components/UserAvatar/UserAvatar.js +59 -44
- package/lib/components/index.d.ts +2 -0
- package/lib/global/js/hooks/index.d.ts +2 -0
- package/lib/global/js/hooks/useFocus.d.ts +11 -0
- package/lib/global/js/hooks/useFocus.js +80 -0
- package/lib/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
- package/lib/global/js/hooks/useIsomorphicEffect.js +18 -0
- package/lib/global/js/package-settings.d.ts +2 -0
- package/lib/global/js/package-settings.js +2 -0
- package/lib/index.js +10 -0
- package/lib/settings.d.ts +2 -0
- package/package.json +7 -7
- package/scss/components/BigNumbers/_big-numbers.scss +151 -0
- package/scss/components/BigNumbers/_carbon-imports.scss +11 -0
- package/scss/components/BigNumbers/_index-with-carbon.scss +9 -0
- package/scss/components/BigNumbers/_index.scss +8 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +19 -0
- package/scss/components/FilterSummary/_filter-summary.scss +1 -1
- package/scss/components/FullPageError/_full-page-error.scss +20 -2
- package/scss/components/ProductiveCard/_productive-card.scss +1 -1
- package/scss/components/SidePanel/_side-panel.scss +1 -1
- package/scss/components/StringFormatter/_carbon-imports.scss +10 -0
- package/scss/components/StringFormatter/_index-with-carbon.scss +9 -0
- package/scss/components/StringFormatter/_index.scss +8 -0
- package/scss/components/StringFormatter/_string-formatter.scss +97 -0
- package/scss/components/Tearsheet/_tearsheet.scss +34 -2
- package/scss/components/UserAvatar/_user-avatar.scss +47 -4
- package/scss/components/_index-with-carbon.scss +2 -0
- package/scss/components/_index.scss +2 -0
- package/es/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.d.ts +0 -2
- package/es/node_modules/@carbon/icon-helpers/es/index.js +0 -140
- package/es/node_modules/@carbon/icons-react/es/Icon.js +0 -73
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-0.js +0 -2985
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-3.js +0 -2900
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3004
- package/es/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +0 -14
- package/lib/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.d.ts +0 -2
- package/lib/node_modules/@carbon/icon-helpers/es/index.js +0 -145
- package/lib/node_modules/@carbon/icons-react/es/Icon.js +0 -81
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-0.js +0 -3117
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-3.js +0 -3032
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3136
- package/lib/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +0 -18
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* BigNumbers is used to display large values in a small area. The display of
|
3
|
+
* values can be the value itself, or grouped in a numerator / denominator fashion.
|
4
|
+
* Control over the total fraction decimals displayed as well as how the
|
5
|
+
* values/totals are displayed are done via a locale prop. Other optional props
|
6
|
+
* allow control over size, truncation, if the value is a percentage, the addition
|
7
|
+
* of a button as well as tool tip functionality.
|
8
|
+
* The default locale is English (`en-US`) if one is not provided or if the provided one is not supported.
|
9
|
+
*/
|
10
|
+
export let BigNumbers: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
11
|
+
import React from 'react';
|
@@ -0,0 +1,238 @@
|
|
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 { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default from 'react';
|
10
|
+
import PropTypes from '../../node_modules/prop-types/index.js';
|
11
|
+
import cx from '../../node_modules/classnames/index.js';
|
12
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
13
|
+
import { pkg } from '../../settings.js';
|
14
|
+
import { Information, ArrowUp } from '@carbon/react/icons';
|
15
|
+
import { Tooltip, SkeletonText } from '@carbon/react';
|
16
|
+
import { DefaultLocale, BigNumbersSize, getSupportedLocale, formatValue, Characters, getIconSize } from './constants.js';
|
17
|
+
import { TooltipTrigger } from '../TooltipTrigger/TooltipTrigger.js';
|
18
|
+
|
19
|
+
var _Information;
|
20
|
+
var _excluded = ["className", "forceShowTotal", "fractionDigits", "iconButton", "loading", "label", "locale", "percentage", "size", "tooltipDescription", "total", "trending", "truncate", "value"],
|
21
|
+
_excluded2 = ["className", "size"];
|
22
|
+
|
23
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
24
|
+
var blockClass = "".concat(pkg.prefix, "--big-numbers");
|
25
|
+
var skeletonBlockClass = "".concat(pkg.prefix, "--big-numbers-skeleton");
|
26
|
+
var componentName = 'BigNumbers';
|
27
|
+
|
28
|
+
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
29
|
+
|
30
|
+
// Default values for props
|
31
|
+
var defaults = {
|
32
|
+
forceShowTotal: false,
|
33
|
+
fractionDigits: 1,
|
34
|
+
loading: false,
|
35
|
+
locale: DefaultLocale,
|
36
|
+
percentage: false,
|
37
|
+
size: BigNumbersSize.Default,
|
38
|
+
total: 0,
|
39
|
+
trending: false,
|
40
|
+
truncate: true,
|
41
|
+
value: null
|
42
|
+
};
|
43
|
+
|
44
|
+
/**
|
45
|
+
* BigNumbers is used to display large values in a small area. The display of
|
46
|
+
* values can be the value itself, or grouped in a numerator / denominator fashion.
|
47
|
+
* Control over the total fraction decimals displayed as well as how the
|
48
|
+
* values/totals are displayed are done via a locale prop. Other optional props
|
49
|
+
* allow control over size, truncation, if the value is a percentage, the addition
|
50
|
+
* of a button as well as tool tip functionality.
|
51
|
+
* The default locale is English (`en-US`) if one is not provided or if the provided one is not supported.
|
52
|
+
*/
|
53
|
+
var BigNumbers = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
54
|
+
var _formatValue, _formatValue2;
|
55
|
+
var className = _ref.className,
|
56
|
+
_ref$forceShowTotal = _ref.forceShowTotal,
|
57
|
+
forceShowTotal = _ref$forceShowTotal === void 0 ? defaults.forceShowTotal : _ref$forceShowTotal,
|
58
|
+
_ref$fractionDigits = _ref.fractionDigits,
|
59
|
+
fractionDigits = _ref$fractionDigits === void 0 ? defaults.fractionDigits : _ref$fractionDigits,
|
60
|
+
iconButton = _ref.iconButton,
|
61
|
+
_ref$loading = _ref.loading,
|
62
|
+
loading = _ref$loading === void 0 ? defaults.loading : _ref$loading,
|
63
|
+
label = _ref.label,
|
64
|
+
_ref$locale = _ref.locale,
|
65
|
+
locale = _ref$locale === void 0 ? defaults.locale : _ref$locale,
|
66
|
+
_ref$percentage = _ref.percentage,
|
67
|
+
percentage = _ref$percentage === void 0 ? defaults.percentage : _ref$percentage,
|
68
|
+
_ref$size = _ref.size,
|
69
|
+
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
70
|
+
tooltipDescription = _ref.tooltipDescription,
|
71
|
+
_ref$total = _ref.total,
|
72
|
+
total = _ref$total === void 0 ? defaults.total : _ref$total,
|
73
|
+
_ref$trending = _ref.trending,
|
74
|
+
trending = _ref$trending === void 0 ? defaults.trending : _ref$trending,
|
75
|
+
_ref$truncate = _ref.truncate,
|
76
|
+
truncate = _ref$truncate === void 0 ? defaults.truncate : _ref$truncate,
|
77
|
+
_ref$value = _ref.value,
|
78
|
+
value = _ref$value === void 0 ? defaults.value : _ref$value,
|
79
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
80
|
+
var BigNumbersClasses = cx(className, _defineProperty(_defineProperty({}, "".concat(blockClass, "--lg"), size === BigNumbersSize.Large), "".concat(blockClass, "--xl"), size === BigNumbersSize.XLarge));
|
81
|
+
var supportedLocale = getSupportedLocale(locale);
|
82
|
+
var truncatedValue = (_formatValue = formatValue(supportedLocale, value, fractionDigits, truncate)) !== null && _formatValue !== void 0 ? _formatValue : Characters.Dash;
|
83
|
+
var truncatedTotal = (_formatValue2 = formatValue(supportedLocale, total, fractionDigits, truncate)) !== null && _formatValue2 !== void 0 ? _formatValue2 : 'Unknown';
|
84
|
+
var shouldDisplayDenominator = !percentage && total > value && truncatedValue !== truncatedTotal || forceShowTotal && total > 0;
|
85
|
+
if (loading) {
|
86
|
+
return /*#__PURE__*/React__default.createElement(SkeletonBigNumbers, _extends({}, rest, {
|
87
|
+
ref: ref,
|
88
|
+
className: className,
|
89
|
+
size: size
|
90
|
+
}, getDevtoolsProps(componentName)));
|
91
|
+
}
|
92
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
93
|
+
className: cx(blockClass, BigNumbersClasses, className),
|
94
|
+
ref: ref
|
95
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement("span", {
|
96
|
+
className: "".concat(blockClass, "__row")
|
97
|
+
}, /*#__PURE__*/React__default.createElement("h4", {
|
98
|
+
className: "".concat(blockClass, "__label")
|
99
|
+
}, label), tooltipDescription && /*#__PURE__*/React__default.createElement(Tooltip, {
|
100
|
+
description: tooltipDescription,
|
101
|
+
align: "right",
|
102
|
+
className: "".concat(blockClass, "__info")
|
103
|
+
}, /*#__PURE__*/React__default.createElement(TooltipTrigger, {
|
104
|
+
className: "".concat(blockClass, "__tooltip-trigger")
|
105
|
+
}, _Information || (_Information = /*#__PURE__*/React__default.createElement(Information, {
|
106
|
+
size: 16
|
107
|
+
}))))), /*#__PURE__*/React__default.createElement("span", {
|
108
|
+
className: "".concat(blockClass, "__row"),
|
109
|
+
role: "math"
|
110
|
+
}, trending && /*#__PURE__*/React__default.createElement(ArrowUp, {
|
111
|
+
className: "".concat(blockClass, "__trend"),
|
112
|
+
size: getIconSize(size)
|
113
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
114
|
+
className: "".concat(blockClass, "__value")
|
115
|
+
}, percentage ? /*#__PURE__*/React__default.createElement("div", {
|
116
|
+
className: "".concat(blockClass, "__percentage")
|
117
|
+
}, truncatedValue, /*#__PURE__*/React__default.createElement("span", {
|
118
|
+
className: "".concat(blockClass, "__percentage-mark")
|
119
|
+
}, "%")) : truncatedValue), shouldDisplayDenominator && /*#__PURE__*/React__default.createElement("span", {
|
120
|
+
className: "".concat(blockClass, "__total")
|
121
|
+
}, /*#__PURE__*/React__default.createElement("span", null, Characters.Slash, truncatedTotal)), iconButton));
|
122
|
+
});
|
123
|
+
|
124
|
+
// Return a placeholder if not released and not enabled by feature flag
|
125
|
+
BigNumbers = pkg.checkComponentEnabled(BigNumbers, componentName);
|
126
|
+
|
127
|
+
// The display name of the component, used by React. Note that displayName
|
128
|
+
// is used in preference to relying on function.name.
|
129
|
+
BigNumbers.displayName = componentName;
|
130
|
+
|
131
|
+
// The types and DocGen commentary for the component props,
|
132
|
+
// in alphabetical order (for consistency).
|
133
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
134
|
+
BigNumbers.propTypes = {
|
135
|
+
/**
|
136
|
+
* Optional class name.
|
137
|
+
* @type number
|
138
|
+
*/
|
139
|
+
className: PropTypes.string,
|
140
|
+
/**
|
141
|
+
* Display the `total` even when the `value` is equal to
|
142
|
+
* the `total` when `forceShowTotal` prop is true on the
|
143
|
+
* condition that the `total` is greater than 0.
|
144
|
+
* @type bool
|
145
|
+
*/
|
146
|
+
forceShowTotal: PropTypes.bool,
|
147
|
+
/**
|
148
|
+
* Optional value to control the maximum fraction digits
|
149
|
+
* used when truncating the value and total.
|
150
|
+
* @type number
|
151
|
+
*/
|
152
|
+
fractionDigits: PropTypes.number,
|
153
|
+
/** Displays an iconButton next to the BigNumbers value
|
154
|
+
* @type node
|
155
|
+
*/
|
156
|
+
iconButton: PropTypes.node,
|
157
|
+
/**
|
158
|
+
* Text label for BigNumbers.
|
159
|
+
* @type string
|
160
|
+
*/
|
161
|
+
label: PropTypes.string.isRequired,
|
162
|
+
/** Specify if the BigNumbers is in a loading state
|
163
|
+
* @type bool
|
164
|
+
*/
|
165
|
+
loading: PropTypes.bool,
|
166
|
+
/**
|
167
|
+
* Locale value to determine approach to formatting numbers.
|
168
|
+
* @type string
|
169
|
+
*/
|
170
|
+
locale: PropTypes.string,
|
171
|
+
/**
|
172
|
+
* Format number to percentage when `percentage` prop is true.
|
173
|
+
* @type bool
|
174
|
+
*/
|
175
|
+
percentage: PropTypes.bool,
|
176
|
+
/** The size of the BigNumbers.
|
177
|
+
* @type string
|
178
|
+
*/
|
179
|
+
size: PropTypes.oneOf(Object.values(BigNumbersSize)),
|
180
|
+
/** Label applied to a Tooltip - marked with the Information icon.
|
181
|
+
* @type string
|
182
|
+
*/
|
183
|
+
tooltipDescription: PropTypes.string,
|
184
|
+
/**
|
185
|
+
* Total value that the main BigNumbers value is a subset of.
|
186
|
+
* @type number
|
187
|
+
*/
|
188
|
+
total: PropTypes.number,
|
189
|
+
/** Display trending icon.
|
190
|
+
* @type boolean
|
191
|
+
*/
|
192
|
+
trending: PropTypes.bool,
|
193
|
+
/** Specify whether or not the values should be truncated.
|
194
|
+
* @type boolean
|
195
|
+
*/
|
196
|
+
truncate: PropTypes.bool,
|
197
|
+
/**
|
198
|
+
* The main BigNumbers value to display
|
199
|
+
* @type number
|
200
|
+
*/
|
201
|
+
value: PropTypes.number
|
202
|
+
};
|
203
|
+
|
204
|
+
/**
|
205
|
+
* SkeletonBigNumbers is used to display a skeleton version while
|
206
|
+
* content is loading (handled by the BigNumbers prop `loading').
|
207
|
+
*
|
208
|
+
* Note: This component is only used within BigNumbers.
|
209
|
+
*/
|
210
|
+
var SkeletonBigNumbers = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref) {
|
211
|
+
var className = _ref2.className,
|
212
|
+
size = _ref2.size,
|
213
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
214
|
+
var BigNumbersSkeletonClasses = cx(className, _defineProperty(_defineProperty({}, "".concat(skeletonBlockClass, "--lg"), size === BigNumbersSize.Large), "".concat(skeletonBlockClass, "--xl"), size === BigNumbersSize.XLarge));
|
215
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
216
|
+
className: cx(className, skeletonBlockClass, BigNumbersSkeletonClasses),
|
217
|
+
ref: ref
|
218
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement(SkeletonText, {
|
219
|
+
className: "".concat(skeletonBlockClass, "__label")
|
220
|
+
}), /*#__PURE__*/React__default.createElement(SkeletonText, {
|
221
|
+
heading: true,
|
222
|
+
className: "".concat(skeletonBlockClass, "__value"),
|
223
|
+
width: "80%"
|
224
|
+
}));
|
225
|
+
});
|
226
|
+
SkeletonBigNumbers.propTypes = {
|
227
|
+
/**
|
228
|
+
* Optional class name.
|
229
|
+
* @type number
|
230
|
+
*/
|
231
|
+
className: PropTypes.string,
|
232
|
+
/** The size of the BigNumbers.
|
233
|
+
* @type string
|
234
|
+
*/
|
235
|
+
size: PropTypes.oneOf(Object.values(BigNumbersSize))
|
236
|
+
};
|
237
|
+
|
238
|
+
export { BigNumbers };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export namespace BigNumbersSize {
|
2
|
+
let Default: string;
|
3
|
+
let Large: string;
|
4
|
+
let XLarge: string;
|
5
|
+
}
|
6
|
+
export namespace Characters {
|
7
|
+
let Dash: string;
|
8
|
+
let Slash: string;
|
9
|
+
}
|
10
|
+
export const DefaultLocale: "en-US";
|
11
|
+
export function formatValue(locale: string, value: number, fractionDigits: number, truncate: boolean): string | null;
|
12
|
+
export function getIconSize(size: string): 16 | 20 | 24;
|
13
|
+
export function getSupportedLocale(locale: string): string;
|
@@ -0,0 +1,67 @@
|
|
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
|
+
/* **************************** | CONSTANTS | ***************************** */
|
9
|
+
|
10
|
+
var BigNumbersSize = {
|
11
|
+
Default: 'default',
|
12
|
+
Large: 'lg',
|
13
|
+
XLarge: 'xl'
|
14
|
+
};
|
15
|
+
var Characters = {
|
16
|
+
Dash: '–',
|
17
|
+
Slash: '/'
|
18
|
+
};
|
19
|
+
var DefaultLocale = 'en-US';
|
20
|
+
|
21
|
+
/* ************************ | UTILITY FUNCTIONS | ************************* */
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Ensure that the value is formatted correctly based on whether it should be truncated or not.
|
25
|
+
* @param {string} locale Locale value to be used in formatting numbers.
|
26
|
+
* @param {number} value The value to format.
|
27
|
+
* @param {number} fractionDigits How many significant figures should be displayed.
|
28
|
+
* @param {boolean} truncate Whether or not the value should be truncated.
|
29
|
+
* @returns {string | null} The formatted value.
|
30
|
+
*/
|
31
|
+
var formatValue = function formatValue(locale, value, fractionDigits, truncate) {
|
32
|
+
if (value === null || value === undefined || typeof value !== 'number') {
|
33
|
+
return null;
|
34
|
+
}
|
35
|
+
return truncate ? Intl.NumberFormat(locale, {
|
36
|
+
notation: 'compact',
|
37
|
+
minimumFractionDigits: 0,
|
38
|
+
maximumFractionDigits: Math.round(fractionDigits)
|
39
|
+
}).format(value) : Intl.NumberFormat(locale).format(value);
|
40
|
+
};
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Function which takes a size and returns a numeric value for sizing icons
|
44
|
+
* @param {string} size Size of desired icon. Expected values are 'default', 'lg', or 'xl'.
|
45
|
+
*/
|
46
|
+
var getIconSize = function getIconSize(size) {
|
47
|
+
switch (size) {
|
48
|
+
case BigNumbersSize.Large:
|
49
|
+
return 20;
|
50
|
+
case BigNumbersSize.XLarge:
|
51
|
+
return 24;
|
52
|
+
default:
|
53
|
+
return 16;
|
54
|
+
}
|
55
|
+
};
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Function which takes a locale and returns a supported locale or the default
|
59
|
+
* @param {string} locale Desired locale for number formatting.
|
60
|
+
*
|
61
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locales
|
62
|
+
*/
|
63
|
+
var getSupportedLocale = function getSupportedLocale(locale) {
|
64
|
+
return Intl.NumberFormat.supportedLocalesOf(locale).length > 0 ? locale : DefaultLocale;
|
65
|
+
};
|
66
|
+
|
67
|
+
export { BigNumbersSize, Characters, DefaultLocale, formatValue, getIconSize, getSupportedLocale };
|
@@ -0,0 +1 @@
|
|
1
|
+
export { BigNumbers } from "./BigNumbers";
|
@@ -1,3 +1,18 @@
|
|
1
|
+
import React, { ReactNode } from 'react';
|
2
|
+
interface CascadeProps {
|
3
|
+
children: ReactNode;
|
4
|
+
/**
|
5
|
+
* Specify an optional className to be applied to
|
6
|
+
* the container node.
|
7
|
+
*/
|
8
|
+
className?: string;
|
9
|
+
/**
|
10
|
+
* Specifies whether or not to wrap the child content in a `<Grid />`.
|
11
|
+
* If this is set to true it's important that the children are being wrapped in rows in columns.
|
12
|
+
* Check the documentation for additional clarification.
|
13
|
+
*/
|
14
|
+
grid?: boolean;
|
15
|
+
}
|
1
16
|
/**
|
2
17
|
|
3
18
|
This pattern is intended for use with cards, tiles, or similarly styled
|
@@ -7,5 +22,7 @@ the page. It should not be used on a page if it is the secondary focus of the
|
|
7
22
|
page as that will distract the user.
|
8
23
|
|
9
24
|
*/
|
10
|
-
export let Cascade: React.ForwardRefExoticComponent<
|
11
|
-
|
25
|
+
export declare let Cascade: React.ForwardRefExoticComponent<CascadeProps & {
|
26
|
+
children?: React.ReactNode;
|
27
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
28
|
+
export {};
|
@@ -53,16 +53,19 @@ var Cascade = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
53
53
|
if (grid) {
|
54
54
|
var colIdx = 0;
|
55
55
|
var gridElm = React__default.Children.map(children, function (row) {
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
if ( /*#__PURE__*/React__default.isValidElement(row)) {
|
57
|
+
var cols = React__default.Children.map(row === null || row === void 0 ? void 0 : row.props.children, function (col) {
|
58
|
+
colIdx = colIdx + 1;
|
59
|
+
var colClassnames = cx(col.props.className, "".concat(blockClass, "__col"), "".concat(blockClass, "__col-").concat(colIdx));
|
60
|
+
return /*#__PURE__*/React__default.cloneElement(col, {
|
61
|
+
className: colClassnames
|
62
|
+
});
|
61
63
|
});
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
64
|
+
return /*#__PURE__*/React__default.cloneElement(row, {
|
65
|
+
children: cols
|
66
|
+
});
|
67
|
+
}
|
68
|
+
return children;
|
66
69
|
});
|
67
70
|
return /*#__PURE__*/React__default.createElement("div", props, /*#__PURE__*/React__default.createElement(Grid, null, gridElm));
|
68
71
|
}
|
@@ -9,12 +9,11 @@ import { objectWithoutProperties as _objectWithoutProperties, extends as _extend
|
|
9
9
|
import React__default from 'react';
|
10
10
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
11
11
|
import cx from '../../node_modules/classnames/index.js';
|
12
|
+
import { Idea, Close } from '@carbon/react/icons';
|
12
13
|
import { Button } from '@carbon/react';
|
13
14
|
import { useCoachmark } from './utils/context.js';
|
14
15
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
15
16
|
import { pkg } from '../../settings.js';
|
16
|
-
import { Idea } from '../../node_modules/@carbon/icons-react/es/generated/bucket-8.js';
|
17
|
-
import { Close } from '../../node_modules/@carbon/icons-react/es/generated/bucket-3.js';
|
18
17
|
|
19
18
|
var _Idea;
|
20
19
|
var _excluded = ["closeIconDescription", "onClose", "theme", "title"];
|
@@ -10,12 +10,12 @@ import React__default, { forwardRef, useRef, useState, useEffect } from 'react';
|
|
10
10
|
import pconsole from '../../global/js/utils/pconsole.js';
|
11
11
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
12
12
|
import cx from '../../node_modules/classnames/index.js';
|
13
|
+
import { Idea } from '@carbon/react/icons';
|
13
14
|
import { Button } from '@carbon/react';
|
14
15
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
15
16
|
import { pkg } from '../../settings.js';
|
16
17
|
import { createPortal } from 'react-dom';
|
17
18
|
import { CoachmarkHeader } from '../Coachmark/CoachmarkHeader.js';
|
18
|
-
import { Idea } from '../../node_modules/@carbon/icons-react/es/generated/bucket-8.js';
|
19
19
|
import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia/SteppedAnimatedMedia.js';
|
20
20
|
|
21
21
|
var _excluded = ["className", "description", "isOpen", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
|
@@ -20,6 +20,7 @@ import { checkActiveHeaderCell } from './utils/checkActiveHeaderCell.js';
|
|
20
20
|
import { checkSelectedHeaderCell } from './utils/checkSelectedHeaderCell.js';
|
21
21
|
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection.js';
|
22
22
|
import { getSpreadsheetWidth } from './utils/getSpreadsheetWidth.js';
|
23
|
+
import { checkForHoldingKey } from './utils/checkForHoldingKey.js';
|
23
24
|
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
24
25
|
import { useSpreadsheetMouseUp } from './hooks/useSpreadsheetMouseUp.js';
|
25
26
|
|
@@ -204,8 +205,8 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
204
205
|
var closestBodyCell = event.target.closest(".".concat(blockClass, "__body--td"));
|
205
206
|
var isValidSelectionAreaStart = closestBodyCell.classList.contains("".concat(blockClass, "__body--td"));
|
206
207
|
setValidStartingPoint(isValidSelectionAreaStart);
|
207
|
-
var isHoldingCommandKey = event
|
208
|
-
var isHoldingShiftKey = event
|
208
|
+
var isHoldingCommandKey = checkForHoldingKey(event, 'cmd');
|
209
|
+
var isHoldingShiftKey = checkForHoldingKey(event, 'shiftKey');
|
209
210
|
setContainerHasFocus(true);
|
210
211
|
var activeCoordinates = {
|
211
212
|
row: cell.row.index,
|
@@ -307,7 +308,7 @@ var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
307
308
|
}, [clickAndHoldActive, currentMatcher, setSelectionAreas]);
|
308
309
|
var handleRowHeaderClick = useCallback(function (index) {
|
309
310
|
return function (event) {
|
310
|
-
var isHoldingCommandKey = event
|
311
|
+
var isHoldingCommandKey = checkForHoldingKey(event, 'cmd');
|
311
312
|
handleHeaderCellSelection({
|
312
313
|
type: 'row',
|
313
314
|
activeCellCoordinates: activeCellCoordinates,
|
@@ -16,6 +16,7 @@ import { checkSelectedHeaderCell } from './utils/checkSelectedHeaderCell.js';
|
|
16
16
|
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection.js';
|
17
17
|
import { selectAllCells } from './utils/selectAllCells.js';
|
18
18
|
import { getSpreadsheetWidth } from './utils/getSpreadsheetWidth.js';
|
19
|
+
import { checkForHoldingKey } from './utils/checkForHoldingKey.js';
|
19
20
|
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
20
21
|
import { useSpreadsheetMouseMove } from './hooks/useSpreadsheetMouseMove.js';
|
21
22
|
|
@@ -62,8 +63,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
62
63
|
}, [cellSize, ref, scrollBarSize, previousState === null || previousState === void 0 ? void 0 : previousState.cellSize]);
|
63
64
|
var handleColumnHeaderClick = function handleColumnHeaderClick(index) {
|
64
65
|
return function (event) {
|
65
|
-
var isHoldingCommandKey = event
|
66
|
-
var isHoldingShiftKey = event
|
66
|
+
var isHoldingCommandKey = checkForHoldingKey(event, 'cmd');
|
67
|
+
var isHoldingShiftKey = checkForHoldingKey(event, 'shiftKey');
|
67
68
|
handleHeaderCellSelection({
|
68
69
|
type: 'column',
|
69
70
|
activeCellCoordinates: activeCellCoordinates,
|
@@ -0,0 +1 @@
|
|
1
|
+
export function checkForHoldingKey(event: any, key: any): any;
|
@@ -0,0 +1,17 @@
|
|
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
|
+
var checkForHoldingKey = function checkForHoldingKey(event, key) {
|
9
|
+
// possible key inputs: altKey,ctrlKey,metaKey,shiftKey
|
10
|
+
if (key == 'cmd') {
|
11
|
+
return event.metaKey || event.ctrlKey;
|
12
|
+
} else {
|
13
|
+
return event[key];
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
17
|
+
export { checkForHoldingKey };
|
@@ -16,7 +16,7 @@ import { DatagridContent } from './DatagridContent.js';
|
|
16
16
|
import { FilterProvider } from './addons/Filtering/FilterProvider.js';
|
17
17
|
import { InlineEditProvider } from './addons/InlineEdit/InlineEditContext/InlineEditContext.js';
|
18
18
|
|
19
|
-
var _excluded = ["datagridState", "title"];
|
19
|
+
var _excluded = ["datagridState", "title", "ariaToolbarLabel"];
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
21
|
var componentName = 'Datagrid';
|
22
22
|
|
@@ -26,6 +26,7 @@ var componentName = 'Datagrid';
|
|
26
26
|
var Datagrid = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
27
27
|
var datagridState = _ref.datagridState,
|
28
28
|
title = _ref.title,
|
29
|
+
ariaToolbarLabel = _ref.ariaToolbarLabel,
|
29
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
30
31
|
if (!datagridState) {
|
31
32
|
pconsole.warn('Datagrid was not passed datagridState which is required to render this component.');
|
@@ -41,7 +42,8 @@ var Datagrid = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
41
42
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
42
43
|
var props = {
|
43
44
|
title: title,
|
44
|
-
datagridState: datagridState
|
45
|
+
datagridState: datagridState,
|
46
|
+
ariaToolbarLabel: ariaToolbarLabel
|
45
47
|
};
|
46
48
|
return /*#__PURE__*/React__default.createElement(FilterProvider, {
|
47
49
|
filters: filters,
|
@@ -62,6 +64,11 @@ Datagrid = pkg.checkComponentEnabled(Datagrid, componentName);
|
|
62
64
|
// is used in preference to relying on function.name.
|
63
65
|
Datagrid.displayName = componentName;
|
64
66
|
Datagrid.propTypes = {
|
67
|
+
/**
|
68
|
+
* Specify a label to be read by screen readers on the container node
|
69
|
+
* 'aria-label' of the TableToolbar component.
|
70
|
+
*/
|
71
|
+
ariaToolbarLabel: PropTypes.string,
|
65
72
|
/**
|
66
73
|
* The data grid state, much of it being supplied by the useDatagrid hook
|
67
74
|
*/
|
@@ -1,9 +1,11 @@
|
|
1
|
-
export function DatagridContent({ datagridState, title }: {
|
1
|
+
export function DatagridContent({ datagridState, title, ariaToolbarLabel }: {
|
2
2
|
datagridState: any;
|
3
3
|
title: any;
|
4
|
+
ariaToolbarLabel: any;
|
4
5
|
}): import("react/jsx-runtime").JSX.Element;
|
5
6
|
export namespace DatagridContent {
|
6
7
|
namespace propTypes {
|
8
|
+
let ariaToolbarLabel: PropTypes.Requireable<string>;
|
7
9
|
let datagridState: PropTypes.Requireable<PropTypes.InferProps<{
|
8
10
|
getTableProps: PropTypes.Requireable<(...args: any[]) => any>;
|
9
11
|
getFilterFlyoutProps: PropTypes.Requireable<(...args: any[]) => any>;
|
@@ -30,7 +30,8 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
30
30
|
var gcClass = "".concat(blockClass, "__grid-container");
|
31
31
|
var DatagridContent = function DatagridContent(_ref) {
|
32
32
|
var datagridState = _ref.datagridState,
|
33
|
-
title = _ref.title
|
33
|
+
title = _ref.title,
|
34
|
+
ariaToolbarLabel = _ref.ariaToolbarLabel;
|
34
35
|
var _useContext = useContext(InlineEditContext),
|
35
36
|
inlineEditState = _useContext.state,
|
36
37
|
dispatch = _useContext.dispatch;
|
@@ -151,7 +152,9 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
151
152
|
className: cx("".concat(gcClass), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(gcClass, "-active"), gridActive), "".concat(gcClass, "-active--without-toolbar"), withInlineEdit && !DatagridActions), "".concat(gcClass, "-inline-edit"), withInlineEdit), "".concat(blockClass, "__full-height"), withVirtualScroll || fullHeightDatagrid), "".concat(blockClass, "__with-pagination"), DatagridPagination), "".concat(blockClass, "__dense-header"), useDenseHeader)),
|
152
153
|
title: gridTitle,
|
153
154
|
description: gridDescription
|
154
|
-
}, /*#__PURE__*/React__default.createElement(DatagridToolbar,
|
155
|
+
}, /*#__PURE__*/React__default.createElement(DatagridToolbar, _extends({}, datagridState, {
|
156
|
+
ariaToolbarLabel: ariaToolbarLabel
|
157
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
155
158
|
className: cx("".concat(blockClass, "__table-container"), _defineProperty({}, "".concat(blockClass, "__table-container--filter-open"), panelOpen)),
|
156
159
|
ref: gridAreaRef
|
157
160
|
}, (filterProps === null || filterProps === void 0 ? void 0 : filterProps.variation) === 'panel' && /*#__PURE__*/React__default.createElement(FilterPanel, _extends({}, getFilterFlyoutProps(), {
|
@@ -171,6 +174,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
171
174
|
}));
|
172
175
|
};
|
173
176
|
DatagridContent.propTypes = {
|
177
|
+
ariaToolbarLabel: PropTypes.string,
|
174
178
|
datagridState: PropTypes.shape({
|
175
179
|
getTableProps: PropTypes.func,
|
176
180
|
getFilterFlyoutProps: PropTypes.func,
|