@carbon/ibm-products 2.29.0-alpha.10 → 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 +1362 -0
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +1362 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +1362 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/AboutModal/AboutModal.d.ts +73 -2
- package/es/components/AboutModal/AboutModal.js +16 -12
- 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/index.d.ts +1 -0
- package/es/global/js/package-settings.d.ts +1 -0
- package/es/global/js/package-settings.js +1 -0
- package/es/index.js +1 -0
- package/es/settings.d.ts +1 -0
- package/lib/components/AboutModal/AboutModal.d.ts +73 -2
- package/lib/components/AboutModal/AboutModal.js +16 -12
- 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/index.d.ts +1 -0
- package/lib/global/js/package-settings.d.ts +1 -0
- package/lib/global/js/package-settings.js +1 -0
- package/lib/index.js +5 -0
- package/lib/settings.d.ts +1 -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/_index-with-carbon.scss +1 -0
- package/scss/components/_index.scss +1 -0
package/es/index.js
CHANGED
@@ -105,6 +105,7 @@ export { InterstitialScreen } from './components/InterstitialScreen/Interstitial
|
|
105
105
|
export { InterstitialScreenView } from './components/InterstitialScreenView/InterstitialScreenView.js';
|
106
106
|
export { InterstitialScreenViewModule } from './components/InterstitialScreenViewModule/InterstitialScreenViewModule.js';
|
107
107
|
export { DelimitedList } from './components/DelimitedList/DelimitedList.js';
|
108
|
+
export { Decorator } from './components/Decorator/Decorator.js';
|
108
109
|
export { DescriptionList } from './components/DescriptionList/DescriptionList.js';
|
109
110
|
export { FullPageError } from './components/FullPageError/FullPageError.js';
|
110
111
|
export { SearchBar } from './components/SearchBar/SearchBar.js';
|
package/es/settings.d.ts
CHANGED
@@ -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<
|
9
|
-
|
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
|
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
|
-
|
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 ? '' :
|
102
|
-
"aria-labelledby": hasScrollingContent ? contentId :
|
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", {
|
@@ -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;
|