@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.
- package/css/index-full-carbon.css +1804 -233
- 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 +40 -8
- 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 +1804 -233
- 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 +1785 -243
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.d.ts +2 -1
- package/es/components/APIKeyModal/APIKeyModal.js +13 -9
- package/es/components/APIKeyModal/APIKeyModal.types.d.ts +206 -0
- package/es/components/AboutModal/AboutModal.d.ts +73 -2
- package/es/components/AboutModal/AboutModal.js +16 -12
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.d.ts +1 -2
- package/es/components/Datagrid/useInitialColumnSort.d.ts +1 -0
- package/es/components/Datagrid/useInitialColumnSort.js +42 -0
- package/es/components/Datagrid/useSortableColumns.d.ts +4 -0
- package/es/components/Datagrid/useSortableColumns.js +16 -16
- package/es/components/Decorator/Decorator.d.ts +5 -0
- package/es/components/Decorator/Decorator.js +348 -0
- package/es/components/Decorator/DecoratorIcon.d.ts +5 -0
- package/es/components/Decorator/DecoratorIcon.js +95 -0
- package/es/components/Decorator/index.d.ts +1 -0
- package/es/components/Decorator/utils.d.ts +8 -0
- package/es/components/Decorator/utils.js +43 -0
- package/es/components/DescriptionList/DescriptionList.d.ts +42 -0
- package/es/components/DescriptionList/DescriptionList.js +88 -0
- package/es/components/DescriptionList/constants.d.ts +6 -0
- package/es/components/DescriptionList/constants.js +16 -0
- package/es/components/DescriptionList/index.d.ts +1 -0
- package/es/components/EmptyStates/EmptyStateContent.d.ts +1 -287
- package/es/components/HTTPErrors/HTTPErrorContent.d.ts +1 -293
- package/es/components/StatusIndicator/StatusIndicator.d.ts +5 -0
- package/es/components/StatusIndicator/StatusIndicator.js +100 -0
- package/es/components/StatusIndicator/StatusIndicatorStep.d.ts +5 -0
- package/es/components/StatusIndicator/index.d.ts +2 -0
- package/es/components/index.d.ts +3 -0
- package/es/global/js/package-settings.d.ts +4 -0
- package/es/global/js/package-settings.js +4 -0
- package/es/index.js +3 -0
- package/es/settings.d.ts +4 -0
- package/lib/components/APIKeyModal/APIKeyModal.d.ts +2 -1
- package/lib/components/APIKeyModal/APIKeyModal.js +13 -9
- package/lib/components/APIKeyModal/APIKeyModal.types.d.ts +206 -0
- package/lib/components/AboutModal/AboutModal.d.ts +73 -2
- package/lib/components/AboutModal/AboutModal.js +16 -12
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +2 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.d.ts +1 -2
- package/lib/components/Datagrid/useInitialColumnSort.d.ts +1 -0
- package/lib/components/Datagrid/useInitialColumnSort.js +46 -0
- package/lib/components/Datagrid/useSortableColumns.d.ts +4 -0
- package/lib/components/Datagrid/useSortableColumns.js +16 -15
- package/lib/components/Decorator/Decorator.d.ts +5 -0
- package/lib/components/Decorator/Decorator.js +355 -0
- package/lib/components/Decorator/DecoratorIcon.d.ts +5 -0
- package/lib/components/Decorator/DecoratorIcon.js +102 -0
- package/lib/components/Decorator/index.d.ts +1 -0
- package/lib/components/Decorator/utils.d.ts +8 -0
- package/lib/components/Decorator/utils.js +48 -0
- package/lib/components/DescriptionList/DescriptionList.d.ts +42 -0
- package/lib/components/DescriptionList/DescriptionList.js +95 -0
- package/lib/components/DescriptionList/constants.d.ts +6 -0
- package/lib/components/DescriptionList/constants.js +20 -0
- package/lib/components/DescriptionList/index.d.ts +1 -0
- package/lib/components/EmptyStates/EmptyStateContent.d.ts +1 -287
- package/lib/components/HTTPErrors/HTTPErrorContent.d.ts +1 -293
- package/lib/components/StatusIndicator/StatusIndicator.d.ts +5 -0
- package/lib/components/StatusIndicator/StatusIndicator.js +107 -0
- package/lib/components/StatusIndicator/StatusIndicatorStep.d.ts +5 -0
- package/lib/components/StatusIndicator/index.d.ts +2 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/global/js/package-settings.d.ts +4 -0
- package/lib/global/js/package-settings.js +4 -0
- package/lib/index.js +15 -0
- package/lib/settings.d.ts +4 -0
- package/package.json +4 -4
- package/scss/components/Decorator/_carbon-imports.scss +9 -0
- package/scss/components/Decorator/_decorator.scss +400 -0
- package/scss/components/Decorator/_index-with-carbon.scss +9 -0
- package/scss/components/Decorator/_index.scss +8 -0
- package/scss/components/DescriptionList/_carbon-imports.scss +9 -0
- package/scss/components/DescriptionList/_description-list.scss +103 -0
- package/scss/components/DescriptionList/_index-with-carbon.scss +9 -0
- package/scss/components/DescriptionList/_index.scss +8 -0
- package/scss/components/SidePanel/_side-panel.scss +6 -1
- package/scss/components/StatusIndicator/_carbon-imports.scss +12 -0
- package/scss/components/StatusIndicator/_index-with-carbon.scss +9 -0
- package/scss/components/StatusIndicator/_index.scss +8 -0
- package/scss/components/StatusIndicator/_status-indicator.scss +93 -0
- package/scss/components/Tearsheet/_tearsheet.scss +41 -15
- package/scss/components/_index-with-carbon.scss +3 -0
- package/scss/components/_index.scss +3 -0
@@ -0,0 +1,355 @@
|
|
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 index = require('../../node_modules/prop-types/index.js');
|
15
|
+
var cx = require('classnames');
|
16
|
+
var devtools = require('../../global/js/utils/devtools.js');
|
17
|
+
var settings = require('../../settings.js');
|
18
|
+
var utils = require('./utils.js');
|
19
|
+
var DecoratorIcon = require('./DecoratorIcon.js');
|
20
|
+
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
22
|
+
|
23
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
24
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
25
|
+
|
26
|
+
var _excluded = ["className", "disabled", "hideIcon", "href", "kind", "label", "setLabelTitle", "onClick", "onClickLabel", "onClickValue", "onContextMenu", "onContextMenuLabel", "onContextMenuValue", "score", "scoreThresholds", "small", "theme", "truncateValue", "value", "valueTitle"];
|
27
|
+
var blockClass = "".concat(settings.pkg.prefix, "--decorator");
|
28
|
+
var componentName = 'Decorator';
|
29
|
+
var defaults = {
|
30
|
+
kind: 'default',
|
31
|
+
onClick: function onClick() {},
|
32
|
+
onClickLabel: function onClickLabel() {},
|
33
|
+
onClickValue: function onClickValue() {},
|
34
|
+
onContextMenu: function onContextMenu() {},
|
35
|
+
onContextMenuLabel: function onContextMenuLabel() {},
|
36
|
+
onContextMenuValue: function onContextMenuValue() {},
|
37
|
+
scoreThresholds: [0, 4, 7, 10],
|
38
|
+
theme: 'light'
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* The Decorator groups a key/value pair to look and behave like a single UI element.
|
43
|
+
*/
|
44
|
+
exports.Decorator = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
45
|
+
var className = _ref.className,
|
46
|
+
disabled = _ref.disabled,
|
47
|
+
hideIcon = _ref.hideIcon,
|
48
|
+
href = _ref.href,
|
49
|
+
_ref$kind = _ref.kind,
|
50
|
+
kind = _ref$kind === void 0 ? defaults.kind : _ref$kind,
|
51
|
+
label = _ref.label,
|
52
|
+
setLabelTitle = _ref.setLabelTitle,
|
53
|
+
_ref$onClick = _ref.onClick,
|
54
|
+
onClick = _ref$onClick === void 0 ? defaults.onClick : _ref$onClick,
|
55
|
+
_ref$onClickLabel = _ref.onClickLabel,
|
56
|
+
onClickLabel = _ref$onClickLabel === void 0 ? defaults.onClickLabel : _ref$onClickLabel,
|
57
|
+
_ref$onClickValue = _ref.onClickValue,
|
58
|
+
onClickValue = _ref$onClickValue === void 0 ? defaults.onClickValue : _ref$onClickValue,
|
59
|
+
_ref$onContextMenu = _ref.onContextMenu,
|
60
|
+
onContextMenu = _ref$onContextMenu === void 0 ? defaults.onContextMenu : _ref$onContextMenu,
|
61
|
+
_ref$onContextMenuLab = _ref.onContextMenuLabel,
|
62
|
+
onContextMenuLabel = _ref$onContextMenuLab === void 0 ? defaults.onContextMenuLabel : _ref$onContextMenuLab,
|
63
|
+
_ref$onContextMenuVal = _ref.onContextMenuValue,
|
64
|
+
onContextMenuValue = _ref$onContextMenuVal === void 0 ? defaults.onContextMenuValue : _ref$onContextMenuVal,
|
65
|
+
score = _ref.score,
|
66
|
+
_ref$scoreThresholds = _ref.scoreThresholds,
|
67
|
+
scoreThresholds = _ref$scoreThresholds === void 0 ? defaults.scoreThresholds : _ref$scoreThresholds,
|
68
|
+
small = _ref.small,
|
69
|
+
_ref$theme = _ref.theme,
|
70
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
71
|
+
truncateValue = _ref.truncateValue,
|
72
|
+
value = _ref.value,
|
73
|
+
valueTitle = _ref.valueTitle,
|
74
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
75
|
+
var magnitude = utils.getMagnitude(score, scoreThresholds);
|
76
|
+
var _labelTitle = setLabelTitle && setLabelTitle(score, scoreThresholds, magnitude);
|
77
|
+
var _value = utils.truncate(value, truncateValue);
|
78
|
+
|
79
|
+
// These class names apply to all types of Decorator.
|
80
|
+
var classNames = cx__default["default"](blockClass, className, "".concat(blockClass, "--").concat(theme), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "--sm"), small), "".concat(blockClass, "--truncate-end"), truncateValue === 'end'), "".concat(blockClass, "--truncate-start"), truncateValue === 'start'), "".concat(blockClass, "--truncate-midline"), truncateValue === null || truncateValue === void 0 ? void 0 : truncateValue.maxLength));
|
81
|
+
|
82
|
+
// These properties apply to all <DecoratorIcons>.
|
83
|
+
var decoratorIconsProps = {
|
84
|
+
className: "".concat(blockClass, "__icon"),
|
85
|
+
magnitude: magnitude.toLowerCase(),
|
86
|
+
// e.g. "Medium" -> "medium"
|
87
|
+
small: small
|
88
|
+
};
|
89
|
+
|
90
|
+
// Optional callback functions if `kind` is "link" or "single-button".
|
91
|
+
var handleOnClick = function handleOnClick(event) {
|
92
|
+
onClick(event, {
|
93
|
+
score: score,
|
94
|
+
label: label,
|
95
|
+
value: value,
|
96
|
+
magnitude: magnitude
|
97
|
+
});
|
98
|
+
};
|
99
|
+
var handleOnContextMenu = function handleOnContextMenu(event) {
|
100
|
+
onContextMenu(event, {
|
101
|
+
score: score,
|
102
|
+
label: label,
|
103
|
+
value: value,
|
104
|
+
magnitude: magnitude
|
105
|
+
});
|
106
|
+
};
|
107
|
+
|
108
|
+
// RETURN DUAL BUTTONS
|
109
|
+
if (kind === 'dual-button') {
|
110
|
+
// Optional callback functions if `kind` is "dual-button" only.
|
111
|
+
var handleOnClickLabel = function handleOnClickLabel(event) {
|
112
|
+
onClickLabel(event, {
|
113
|
+
score: score,
|
114
|
+
label: label,
|
115
|
+
value: value,
|
116
|
+
magnitude: magnitude
|
117
|
+
});
|
118
|
+
};
|
119
|
+
var handleOnClickValue = function handleOnClickValue(event) {
|
120
|
+
onClickValue(event, {
|
121
|
+
score: score,
|
122
|
+
label: label,
|
123
|
+
value: value,
|
124
|
+
magnitude: magnitude
|
125
|
+
});
|
126
|
+
};
|
127
|
+
var handleOnContextMenuLabel = function handleOnContextMenuLabel(event) {
|
128
|
+
onContextMenuLabel(event, {
|
129
|
+
score: score,
|
130
|
+
label: label,
|
131
|
+
value: value,
|
132
|
+
magnitude: magnitude
|
133
|
+
});
|
134
|
+
};
|
135
|
+
var handleOnContextMenuValue = function handleOnContextMenuValue(event) {
|
136
|
+
onContextMenuValue(event, {
|
137
|
+
score: score,
|
138
|
+
label: label,
|
139
|
+
value: value,
|
140
|
+
magnitude: magnitude
|
141
|
+
});
|
142
|
+
};
|
143
|
+
return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({}, rest, devtools.getDevtoolsProps(componentName), {
|
144
|
+
className: cx__default["default"](classNames, "".concat(blockClass, "--buttons"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "-disabled"), disabled)),
|
145
|
+
ref: ref
|
146
|
+
}), /*#__PURE__*/React__default["default"].createElement("button", {
|
147
|
+
className: "".concat(blockClass, "__label"),
|
148
|
+
disabled: disabled,
|
149
|
+
onClick: !disabled && handleOnClickLabel,
|
150
|
+
onContextMenu: !disabled && handleOnContextMenuLabel,
|
151
|
+
title: _labelTitle || label,
|
152
|
+
type: "button"
|
153
|
+
}, !hideIcon && /*#__PURE__*/React__default["default"].createElement(DecoratorIcon.DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default["default"].createElement("button", {
|
154
|
+
className: "".concat(blockClass, "__value"),
|
155
|
+
disabled: disabled,
|
156
|
+
onClick: !disabled && handleOnClickValue,
|
157
|
+
onContextMenu: !disabled && handleOnContextMenuValue,
|
158
|
+
title: valueTitle || value,
|
159
|
+
type: "button"
|
160
|
+
}, _value));
|
161
|
+
}
|
162
|
+
|
163
|
+
// RETURN SINGLE BUTTON
|
164
|
+
if (kind === 'single-button') {
|
165
|
+
return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, devtools.getDevtoolsProps(componentName), {
|
166
|
+
className: cx__default["default"](classNames, "".concat(blockClass, "--button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "-disabled"), disabled)),
|
167
|
+
disabled: disabled,
|
168
|
+
onClick: !disabled && handleOnClick,
|
169
|
+
onContextMenu: !disabled && handleOnContextMenu,
|
170
|
+
ref: ref,
|
171
|
+
type: "button"
|
172
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
173
|
+
className: "".concat(blockClass, "__label"),
|
174
|
+
title: _labelTitle || label
|
175
|
+
}, !hideIcon && /*#__PURE__*/React__default["default"].createElement(DecoratorIcon.DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default["default"].createElement("span", {
|
176
|
+
className: "".concat(blockClass, "__value"),
|
177
|
+
title: valueTitle || value
|
178
|
+
}, _value));
|
179
|
+
}
|
180
|
+
|
181
|
+
// RETURN LINK
|
182
|
+
if (kind === 'link') {
|
183
|
+
return /*#__PURE__*/React__default["default"].createElement("a", _rollupPluginBabelHelpers["extends"]({}, rest, devtools.getDevtoolsProps(componentName), {
|
184
|
+
href: href,
|
185
|
+
className: cx__default["default"](classNames, "".concat(blockClass, "--link")),
|
186
|
+
onClick: handleOnClick,
|
187
|
+
onContextMenu: handleOnContextMenu,
|
188
|
+
ref: ref
|
189
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
190
|
+
className: "".concat(blockClass, "__label"),
|
191
|
+
title: _labelTitle || label
|
192
|
+
}, !hideIcon && /*#__PURE__*/React__default["default"].createElement(DecoratorIcon.DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default["default"].createElement("span", {
|
193
|
+
className: "".concat(blockClass, "__value"),
|
194
|
+
title: valueTitle || value
|
195
|
+
}, _value));
|
196
|
+
}
|
197
|
+
|
198
|
+
// RETURN DEFAULT (NON-INTERACTIVE)
|
199
|
+
if (kind === 'default') {
|
200
|
+
return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({}, rest, devtools.getDevtoolsProps(componentName), {
|
201
|
+
className: cx__default["default"](classNames, "".concat(blockClass, "--default")),
|
202
|
+
ref: ref
|
203
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
204
|
+
className: "".concat(blockClass, "__label"),
|
205
|
+
title: _labelTitle || label
|
206
|
+
}, !hideIcon && /*#__PURE__*/React__default["default"].createElement(DecoratorIcon.DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default["default"].createElement("span", {
|
207
|
+
className: "".concat(blockClass, "__value"),
|
208
|
+
title: valueTitle || value
|
209
|
+
}, _value));
|
210
|
+
}
|
211
|
+
});
|
212
|
+
|
213
|
+
// Return a placeholder if not released and not enabled by feature flag
|
214
|
+
exports.Decorator = settings.pkg.checkComponentEnabled(exports.Decorator, componentName);
|
215
|
+
|
216
|
+
// The display name of the component, used by React. Note that displayName
|
217
|
+
// is used in preference to relying on function.name.
|
218
|
+
exports.Decorator.displayName = componentName;
|
219
|
+
|
220
|
+
// The types and DocGen commentary for the component props,
|
221
|
+
// in alphabetical order (for consistency).
|
222
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
223
|
+
exports.Decorator.propTypes = {
|
224
|
+
/**
|
225
|
+
* Provide an optional class to be applied to the containing node.
|
226
|
+
*/
|
227
|
+
className: index["default"].string,
|
228
|
+
/**
|
229
|
+
* `disabled` only applies if `kind` is "single-button" or "dual-button".
|
230
|
+
*/
|
231
|
+
disabled: index["default"].bool,
|
232
|
+
/**
|
233
|
+
* Do not show the icon, regardless of score.
|
234
|
+
*/
|
235
|
+
hideIcon: index["default"].bool,
|
236
|
+
/**
|
237
|
+
* `href` is req'd if `kind` is "link".
|
238
|
+
*
|
239
|
+
* These two properties together will render the `label` and `value` as a single anchor tag.
|
240
|
+
*/
|
241
|
+
href: index["default"].string,
|
242
|
+
/**
|
243
|
+
* If `kind` is "dual-button" then refer to the `onClickLabel`, `onClickValue`, `onContextMenuLabel`, and `onContextMenuValue` callback functions.
|
244
|
+
*
|
245
|
+
* If `kind` is "single-button" then refer to the `onClick` and `onContextMenu` callback functions.
|
246
|
+
*
|
247
|
+
* If `kind` is "link" then also populate `href`.
|
248
|
+
*
|
249
|
+
* `kind's` default value is "default" and has no other requirements.
|
250
|
+
*/
|
251
|
+
kind: index["default"].oneOf(['default', 'link', 'single-button', 'dual-button']),
|
252
|
+
/**
|
253
|
+
* The label for the data.
|
254
|
+
*/
|
255
|
+
label: index["default"].string,
|
256
|
+
/**
|
257
|
+
* Optional callback function if `kind` is "link" or "single-button".
|
258
|
+
*
|
259
|
+
* Returns two objects: `event` and `{ score, label, value, magnitude }`
|
260
|
+
*/
|
261
|
+
onClick: index["default"].func,
|
262
|
+
/**
|
263
|
+
* Optional callback functions if `kind` is "dual-button" only.
|
264
|
+
*
|
265
|
+
* Returns two objects: `event` and `{ score, label, value, magnitude }`
|
266
|
+
*/
|
267
|
+
onClickLabel: index["default"].func,
|
268
|
+
/**
|
269
|
+
* Optional callback functions if `kind` is "dual-button" only.
|
270
|
+
*
|
271
|
+
* Returns two objects: `event` and `{ score, label, value, magnitude }`
|
272
|
+
*/
|
273
|
+
onClickValue: index["default"].func,
|
274
|
+
/**
|
275
|
+
* Optional callback function if `kind` is "link" or "single-button".
|
276
|
+
*
|
277
|
+
* Returns two objects: `event` and `{ score, label, value, magnitude }`
|
278
|
+
*/
|
279
|
+
onContextMenu: index["default"].func,
|
280
|
+
/**
|
281
|
+
* Optional callback functions if `kind` is "dual-button" only.
|
282
|
+
*
|
283
|
+
* Returns two objects: `event` and `{ score, label, value, magnitude }`
|
284
|
+
*/
|
285
|
+
onContextMenuLabel: index["default"].func,
|
286
|
+
/**
|
287
|
+
* Optional callback functions if `kind` is "dual-button" only.
|
288
|
+
*
|
289
|
+
* Returns two objects: `event` and `{ score, label, value, magnitude }`
|
290
|
+
*/
|
291
|
+
onContextMenuValue: index["default"].func,
|
292
|
+
/**
|
293
|
+
* Used in conjunction with `scoreThresholds`, determines the color, shape, and type of magnitude of the icon.
|
294
|
+
*
|
295
|
+
* If you don't want to show the icon at all, set `hideIcon={true}`.
|
296
|
+
*/
|
297
|
+
score: index["default"].number,
|
298
|
+
/**
|
299
|
+
* Used in conjunction with `score`, determines the color, shape, and type of magnitude of the icon.
|
300
|
+
*
|
301
|
+
* An array of 4 numbers determines the range of thresholds.
|
302
|
+
*
|
303
|
+
* Example using `[0, 4, 7, 10]`:
|
304
|
+
* <br/>- `<= 0` "Benign"
|
305
|
+
* <br/>- `1-3` "Low"
|
306
|
+
* <br/>- `4-6` "Medium"
|
307
|
+
* <br/>- `7-9` "High"
|
308
|
+
* <br/>- `>= 10` "Critical"
|
309
|
+
* <br/>- `NaN` "Unknown"
|
310
|
+
*/
|
311
|
+
scoreThresholds: index["default"].arrayOf(index["default"].number),
|
312
|
+
/**
|
313
|
+
* Callback function for building the label's descriptive text for screen readers.
|
314
|
+
*
|
315
|
+
* The default description is in the form of `"(magnitude)" magnitude: score X out of Y"`.
|
316
|
+
* E.g. `"Medium" magnitude: score 5 out of 10`.
|
317
|
+
*
|
318
|
+
* Where `magnitude` is the label associated with the specific score,
|
319
|
+
* X is the `score`, and Y is the last element of the `setLabelTitle` array.
|
320
|
+
*
|
321
|
+
* If not defined, the title will default to the `label` prop.
|
322
|
+
*/
|
323
|
+
setLabelTitle: index["default"].func,
|
324
|
+
/**
|
325
|
+
* Styled smaller to better fit inline with text.
|
326
|
+
*/
|
327
|
+
small: index["default"].bool,
|
328
|
+
/**
|
329
|
+
* Determines the theme of the component.
|
330
|
+
*/
|
331
|
+
theme: index["default"].oneOf(['light', 'dark']),
|
332
|
+
/**
|
333
|
+
* If not defined, it will behave as `display:inline-block`.
|
334
|
+
*
|
335
|
+
* If `end` it will append "..." to the `value` if there is not enough space.
|
336
|
+
*
|
337
|
+
* If `start` it will prepend "..." to the `value` if there is not enough space.
|
338
|
+
*
|
339
|
+
* If `{maxLength, front, back}` it will inject "..." in the middle
|
340
|
+
* of the `value` regardless of available space.
|
341
|
+
*/
|
342
|
+
truncateValue: index["default"].oneOfType([index["default"].oneOf(['end', 'start']), index["default"].shape({
|
343
|
+
maxLength: index["default"].number,
|
344
|
+
front: index["default"].number,
|
345
|
+
back: index["default"].number
|
346
|
+
})]),
|
347
|
+
/**
|
348
|
+
* The value of the data.
|
349
|
+
*/
|
350
|
+
value: index["default"].string.isRequired,
|
351
|
+
/**
|
352
|
+
* Overrides the default title for the Decorator's value.
|
353
|
+
*/
|
354
|
+
valueTitle: index["default"].string
|
355
|
+
};
|
@@ -0,0 +1,102 @@
|
|
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 index = require('../../node_modules/prop-types/index.js');
|
15
|
+
var cx = require('classnames');
|
16
|
+
var icons = require('@carbon/react/icons');
|
17
|
+
var devtools = require('../../global/js/utils/devtools.js');
|
18
|
+
var settings = require('../../settings.js');
|
19
|
+
|
20
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
21
|
+
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
23
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
24
|
+
|
25
|
+
var _excluded = ["className", "magnitude", "small"];
|
26
|
+
|
27
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
28
|
+
var blockClass = "".concat(settings.pkg.prefix, "--decorator-icon");
|
29
|
+
var componentName = 'DecoratorIcon';
|
30
|
+
var defaults = {
|
31
|
+
magnitude: 'unknown',
|
32
|
+
small: false
|
33
|
+
};
|
34
|
+
|
35
|
+
/**
|
36
|
+
* The shape and color of the Decorator's icon.
|
37
|
+
*/
|
38
|
+
exports.DecoratorIcon = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
39
|
+
var className = _ref.className,
|
40
|
+
_ref$magnitude = _ref.magnitude,
|
41
|
+
magnitude = _ref$magnitude === void 0 ? defaults.magnitude : _ref$magnitude,
|
42
|
+
_ref$small = _ref.small,
|
43
|
+
small = _ref$small === void 0 ? defaults.small : _ref$small,
|
44
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
45
|
+
var Icon;
|
46
|
+
switch (magnitude) {
|
47
|
+
case 'benign':
|
48
|
+
Icon = icons.CircleFill;
|
49
|
+
break;
|
50
|
+
case 'low':
|
51
|
+
Icon = icons.SquareFill;
|
52
|
+
break;
|
53
|
+
case 'medium':
|
54
|
+
Icon = icons.DiamondFill;
|
55
|
+
break;
|
56
|
+
case 'high':
|
57
|
+
Icon = icons.Caution;
|
58
|
+
break;
|
59
|
+
case 'critical':
|
60
|
+
Icon = icons.ChevronMini;
|
61
|
+
break;
|
62
|
+
default:
|
63
|
+
Icon = icons.CircleStroke;
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
return /*#__PURE__*/React__default["default"].createElement(Icon, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
67
|
+
"aria-hidden": true,
|
68
|
+
className: cx__default["default"](blockClass, className, "".concat(blockClass, "__magnitude-").concat(magnitude), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "--sm"), small)),
|
69
|
+
focusable: false,
|
70
|
+
ref: ref
|
71
|
+
// Adding viewBox allows resizing `svg` elements via CSS.
|
72
|
+
// The "ChevronMini" icon is half size,
|
73
|
+
// so set to '8 8 8 8' to match the size of the other icons.
|
74
|
+
,
|
75
|
+
viewBox: magnitude === 'critical' ? '8 8 8 8' : '0 0 16 16'
|
76
|
+
}, devtools.getDevtoolsProps(componentName)));
|
77
|
+
});
|
78
|
+
|
79
|
+
// Return a placeholder if not released and not enabled by feature flag
|
80
|
+
exports.DecoratorIcon = settings.pkg.checkComponentEnabled(exports.DecoratorIcon, componentName);
|
81
|
+
|
82
|
+
// The display name of the component, used by React. Note that displayName
|
83
|
+
// is used in preference to relying on function.name.
|
84
|
+
exports.DecoratorIcon.displayName = componentName;
|
85
|
+
|
86
|
+
// The types and DocGen commentary for the component props,
|
87
|
+
// in alphabetical order (for consistency).
|
88
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
89
|
+
exports.DecoratorIcon.propTypes = {
|
90
|
+
/**
|
91
|
+
* Provide an optional class to be applied to the containing node.
|
92
|
+
*/
|
93
|
+
className: index["default"].string,
|
94
|
+
/**
|
95
|
+
* Determines the shape and color of the icon.
|
96
|
+
*/
|
97
|
+
magnitude: index["default"].oneOf(['unknown', 'benign', 'low', 'medium', 'high', 'critical']),
|
98
|
+
/**
|
99
|
+
* Reduce the size of the icon in proportion to a smaller Decorator.
|
100
|
+
*/
|
101
|
+
small: index["default"].bool
|
102
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Decorator } from "./Decorator";
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024, 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
|
+
export function getMagnitude(score: any, thresholds: any): "Medium" | "Unknown" | "Benign" | "Low" | "High" | "Critical";
|
8
|
+
export function truncate(inputText: any, truncateValue?: {}): any;
|
@@ -0,0 +1,48 @@
|
|
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 getMagnitude = function getMagnitude(score, thresholds) {
|
13
|
+
if (typeof score === 'number') {
|
14
|
+
if (score <= thresholds[0]) {
|
15
|
+
return 'Benign';
|
16
|
+
}
|
17
|
+
if (score < thresholds[1]) {
|
18
|
+
return 'Low';
|
19
|
+
}
|
20
|
+
if (score < thresholds[2]) {
|
21
|
+
return 'Medium';
|
22
|
+
}
|
23
|
+
if (score < thresholds[3]) {
|
24
|
+
return 'High';
|
25
|
+
}
|
26
|
+
if (score >= thresholds[3]) {
|
27
|
+
return 'Critical';
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return 'Unknown';
|
31
|
+
};
|
32
|
+
|
33
|
+
// If a "midline" truncation has been defined,
|
34
|
+
// then return the formatted midline value generated here,
|
35
|
+
// else return to the original value.
|
36
|
+
var truncate = function truncate(inputText) {
|
37
|
+
var truncateValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
38
|
+
var maxLength = truncateValue.maxLength,
|
39
|
+
front = truncateValue.front,
|
40
|
+
back = truncateValue.back;
|
41
|
+
if (maxLength && inputText.length > maxLength) {
|
42
|
+
return "".concat(inputText.substring(0, front), "\u2026").concat(inputText.substr(inputText.length - back));
|
43
|
+
}
|
44
|
+
return inputText;
|
45
|
+
};
|
46
|
+
|
47
|
+
exports.getMagnitude = getMagnitude;
|
48
|
+
exports.truncate = truncate;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Type layouts provide an orderly layout of terms and definitions.
|
3
|
+
*/
|
4
|
+
export let DescriptionList: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
5
|
+
export function DescriptionListBody({ children, className, ...rest }: {
|
6
|
+
[x: string]: any;
|
7
|
+
children: any;
|
8
|
+
className: any;
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
10
|
+
export namespace DescriptionListBody {
|
11
|
+
export namespace propTypes {
|
12
|
+
let children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
13
|
+
let className: PropTypes.Requireable<string>;
|
14
|
+
}
|
15
|
+
export { componentNameBody as displayName };
|
16
|
+
}
|
17
|
+
export function DescriptionListRow({ children, className, ...other }: {
|
18
|
+
[x: string]: any;
|
19
|
+
children: any;
|
20
|
+
className: any;
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
22
|
+
export namespace DescriptionListRow {
|
23
|
+
export namespace propTypes_1 { }
|
24
|
+
export { propTypes_1 as propTypes };
|
25
|
+
export { componentNameRow as displayName };
|
26
|
+
}
|
27
|
+
export function DescriptionListCell({ children, className, ...rest }: {
|
28
|
+
[x: string]: any;
|
29
|
+
children: any;
|
30
|
+
className: any;
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|
32
|
+
export namespace DescriptionListCell {
|
33
|
+
export namespace propTypes_2 { }
|
34
|
+
export { propTypes_2 as propTypes };
|
35
|
+
export { componentNameCell as displayName };
|
36
|
+
}
|
37
|
+
import React from 'react';
|
38
|
+
import PropTypes from 'prop-types';
|
39
|
+
declare const componentNameBody: "DescriptionListBody";
|
40
|
+
declare const componentNameRow: "DescriptionListRow";
|
41
|
+
declare const componentNameCell: "DescriptionListCell";
|
42
|
+
export {};
|
@@ -0,0 +1,95 @@
|
|
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 index = require('../../node_modules/prop-types/index.js');
|
15
|
+
var cx = require('classnames');
|
16
|
+
var devtools = require('../../global/js/utils/devtools.js');
|
17
|
+
var settings = require('../../settings.js');
|
18
|
+
var constants = require('./constants.js');
|
19
|
+
var react = require('@carbon/react');
|
20
|
+
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
22
|
+
|
23
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
24
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
25
|
+
|
26
|
+
var _excluded = ["border", "children", "className", "size"];
|
27
|
+
|
28
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
29
|
+
var blockClass = "".concat(settings.pkg.prefix, "--description-list");
|
30
|
+
var componentName = 'DescriptionList';
|
31
|
+
|
32
|
+
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
33
|
+
|
34
|
+
// Default values can be included here and then assigned to the prop params,
|
35
|
+
// e.g. prop = defaults.prop,
|
36
|
+
// This gathers default values together neatly and ensures non-primitive
|
37
|
+
// values are initialized early to avoid react making unnecessary re-renders.
|
38
|
+
// Note that default values are not required for props that are 'required',
|
39
|
+
// nor for props where the component can apply undefined values reasonably.
|
40
|
+
// Default values should be provided when the component needs to make a choice
|
41
|
+
// or assumption when a prop is not supplied.
|
42
|
+
|
43
|
+
// Default values for props
|
44
|
+
var defaults = {
|
45
|
+
border: false,
|
46
|
+
size: constants.DescriptionListSize.Medium
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Type layouts provide an orderly layout of terms and definitions.
|
51
|
+
*/
|
52
|
+
exports.DescriptionList = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
53
|
+
var _ref$border = _ref.border,
|
54
|
+
border = _ref$border === void 0 ? defaults.border : _ref$border,
|
55
|
+
children = _ref.children,
|
56
|
+
className = _ref.className,
|
57
|
+
_ref$size = _ref.size,
|
58
|
+
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
59
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
60
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
61
|
+
className: cx__default["default"](blockClass, // Apply the block class to the main HTML element
|
62
|
+
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "--bordered"), border), "".concat(blockClass, "--").concat(size), size), className // Apply any supplied class names to the main HTML element.
|
63
|
+
),
|
64
|
+
ref: ref
|
65
|
+
}, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React__default["default"].createElement(react.StructuredListWrapper, {
|
66
|
+
role: "table",
|
67
|
+
selection: false
|
68
|
+
}, children));
|
69
|
+
});
|
70
|
+
|
71
|
+
// Return a placeholder if not released and not enabled by feature flag
|
72
|
+
exports.DescriptionList = settings.pkg.checkComponentEnabled(exports.DescriptionList, componentName);
|
73
|
+
|
74
|
+
// The display name of the component, used by React. Note that displayName
|
75
|
+
// is used in preference to relying on function.name.
|
76
|
+
exports.DescriptionList.displayName = componentName;
|
77
|
+
var propTypes = {
|
78
|
+
/** Provide the contents of the node */
|
79
|
+
children: index["default"].node,
|
80
|
+
/** Provide an optional class to be applied to the containing node */
|
81
|
+
className: index["default"].string
|
82
|
+
};
|
83
|
+
|
84
|
+
// The types and DocGen commentary for the component props,
|
85
|
+
// in alphabetical order (for consistency).
|
86
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
87
|
+
exports.DescriptionList.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, propTypes), {}, {
|
88
|
+
/** Specify if the type layout has a border */
|
89
|
+
border: index["default"].bool,
|
90
|
+
/** Specify the size of the type layout, from a list of available sizes */
|
91
|
+
size: index["default"].oneOf(Object.values(constants.DescriptionListSize))
|
92
|
+
});
|
93
|
+
_rollupPluginBabelHelpers.objectSpread2({}, propTypes);
|
94
|
+
_rollupPluginBabelHelpers.objectSpread2({}, propTypes);
|
95
|
+
_rollupPluginBabelHelpers.objectSpread2({}, propTypes);
|