@carbon/ibm-products 2.31.0-alpha.5 → 2.31.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/css/index-full-carbon.css +808 -517
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +54 -75
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +808 -517
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +737 -458
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/CreateModal/CreateModal.d.ts +66 -2
  18. package/es/components/CreateModal/CreateModal.js +1 -1
  19. package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
  20. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.d.ts +3 -1
  21. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +4 -1
  22. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +3 -15
  23. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +0 -7
  24. package/es/components/Decorator/Decorator.d.ts +1 -1
  25. package/es/components/Decorator/Decorator.js +16 -253
  26. package/es/components/DecoratorBase/DecoratorBase.d.ts +7 -0
  27. package/es/components/DecoratorBase/DecoratorBase.js +233 -0
  28. package/es/components/DecoratorBase/index.d.ts +1 -0
  29. package/{lib/components/Decorator → es/components/DecoratorBase}/utils.d.ts +1 -1
  30. package/es/components/{Decorator → DecoratorBase}/utils.js +19 -19
  31. package/es/components/DecoratorDualButton/DecoratorDualButton.d.ts +5 -0
  32. package/es/components/DecoratorDualButton/DecoratorDualButton.js +135 -0
  33. package/es/components/DecoratorDualButton/index.d.ts +1 -0
  34. package/es/components/DecoratorLink/DecoratorLink.d.ts +5 -0
  35. package/es/components/DecoratorLink/DecoratorLink.js +125 -0
  36. package/es/components/DecoratorLink/index.d.ts +1 -0
  37. package/es/components/DecoratorSingleButton/DecoratorSingleButton.d.ts +5 -0
  38. package/es/components/DecoratorSingleButton/DecoratorSingleButton.js +125 -0
  39. package/es/components/DecoratorSingleButton/index.d.ts +1 -0
  40. package/es/components/index.d.ts +3 -0
  41. package/es/global/js/hooks/useFocus.js +2 -1
  42. package/es/global/js/package-settings.d.ts +3 -0
  43. package/es/global/js/package-settings.js +3 -0
  44. package/es/index.js +3 -0
  45. package/es/settings.d.ts +3 -0
  46. package/lib/components/CreateModal/CreateModal.d.ts +66 -2
  47. package/lib/components/CreateModal/CreateModal.js +1 -1
  48. package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
  49. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.d.ts +3 -1
  50. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +4 -1
  51. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +3 -15
  52. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +0 -7
  53. package/lib/components/Decorator/Decorator.d.ts +1 -1
  54. package/lib/components/Decorator/Decorator.js +15 -253
  55. package/lib/components/DecoratorBase/DecoratorBase.d.ts +7 -0
  56. package/lib/components/DecoratorBase/DecoratorBase.js +242 -0
  57. package/lib/components/DecoratorBase/index.d.ts +1 -0
  58. package/{es/components/Decorator → lib/components/DecoratorBase}/utils.d.ts +1 -1
  59. package/lib/components/{Decorator → DecoratorBase}/utils.js +19 -19
  60. package/lib/components/DecoratorDualButton/DecoratorDualButton.d.ts +5 -0
  61. package/lib/components/DecoratorDualButton/DecoratorDualButton.js +141 -0
  62. package/lib/components/DecoratorDualButton/index.d.ts +1 -0
  63. package/lib/components/DecoratorLink/DecoratorLink.d.ts +5 -0
  64. package/lib/components/DecoratorLink/DecoratorLink.js +131 -0
  65. package/lib/components/DecoratorLink/index.d.ts +1 -0
  66. package/lib/components/DecoratorSingleButton/DecoratorSingleButton.d.ts +5 -0
  67. package/lib/components/DecoratorSingleButton/DecoratorSingleButton.js +131 -0
  68. package/lib/components/DecoratorSingleButton/index.d.ts +1 -0
  69. package/lib/components/index.d.ts +3 -0
  70. package/lib/global/js/hooks/useFocus.js +2 -1
  71. package/lib/global/js/package-settings.d.ts +3 -0
  72. package/lib/global/js/package-settings.js +3 -0
  73. package/lib/index.js +15 -0
  74. package/lib/settings.d.ts +3 -0
  75. package/package.json +9 -9
  76. package/scss/components/Card/_card.scss +2 -2
  77. package/scss/components/Datagrid/styles/_draggableElement.scss +5 -1
  78. package/scss/components/Decorator/_decorator.scss +3 -380
  79. package/scss/components/DecoratorBase/_carbon-imports.scss +9 -0
  80. package/scss/components/DecoratorBase/_decorator-base-mixins.scss +41 -0
  81. package/scss/components/DecoratorBase/_decorator-base.scss +146 -0
  82. package/scss/components/DecoratorBase/_index-with-carbon.scss +9 -0
  83. package/scss/components/DecoratorBase/_index.scss +8 -0
  84. package/scss/components/DecoratorDualButton/_carbon-imports.scss +9 -0
  85. package/scss/components/DecoratorDualButton/_decorator-dual-button.scss +112 -0
  86. package/scss/components/DecoratorDualButton/_index-with-carbon.scss +9 -0
  87. package/scss/components/DecoratorDualButton/_index.scss +8 -0
  88. package/scss/components/DecoratorLink/_carbon-imports.scss +9 -0
  89. package/scss/components/DecoratorLink/_decorator-link.scss +53 -0
  90. package/scss/components/DecoratorLink/_index-with-carbon.scss +9 -0
  91. package/scss/components/DecoratorLink/_index.scss +8 -0
  92. package/scss/components/DecoratorSingleButton/_carbon-imports.scss +9 -0
  93. package/scss/components/DecoratorSingleButton/_decorator-single-button.scss +117 -0
  94. package/scss/components/DecoratorSingleButton/_index-with-carbon.scss +9 -0
  95. package/scss/components/DecoratorSingleButton/_index.scss +8 -0
  96. package/scss/components/SidePanel/_side-panel.scss +1 -1
  97. package/scss/components/Tearsheet/_tearsheet.scss +1 -1
  98. package/scss/components/_index-with-carbon.scss +3 -0
  99. package/scss/components/_index.scss +3 -0
  100. /package/es/components/{Decorator → DecoratorBase}/DecoratorIcon.d.ts +0 -0
  101. /package/es/components/{Decorator → DecoratorBase}/DecoratorIcon.js +0 -0
  102. /package/lib/components/{Decorator → DecoratorBase}/DecoratorIcon.d.ts +0 -0
  103. /package/lib/components/{Decorator → DecoratorBase}/DecoratorIcon.js +0 -0
@@ -1,8 +1,72 @@
1
+ /**
2
+ * Copyright IBM Corp. 2021, 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
+ /// <reference path="../../../src/custom-typings/index.d.ts" />
8
+ import React, { ReactNode } from 'react';
9
+ import { ComposedModal } from '@carbon/react';
10
+ interface CreateModalProps extends React.ComponentProps<typeof ComposedModal> {
11
+ /**
12
+ * Specify an optional className to be applied to the modal root node
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Specifies an optional handler which is called when the CreateModal
17
+ * is closed.
18
+ */
19
+ onRequestClose?(): void;
20
+ /**
21
+ * Specifies an optional handler which is called when the CreateModal
22
+ * primary button is pressed.
23
+ */
24
+ onRequestSubmit?(): void;
25
+ /**
26
+ * Specifies whether the CreateModal is open or not.
27
+ */
28
+ open?: boolean;
29
+ /**
30
+ * The title of the CreateModal is usually the product or service name.
31
+ */
32
+ title: ReactNode;
33
+ /**
34
+ * The subtitle of the CreateModal is optional and serves to provide more information about the modal.
35
+ */
36
+ subtitle?: ReactNode;
37
+ /**
38
+ * The description of the CreateModal serves to provide more information about the modal.
39
+ */
40
+ description: ReactNode;
41
+ /**
42
+ * Specifies the secondary button's text in the modal.
43
+ */
44
+ secondaryButtonText: string;
45
+ /**
46
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
47
+ */
48
+ portalTarget?: ReactNode;
49
+ /**
50
+ * Specifies the primary button's text in the modal.
51
+ */
52
+ primaryButtonText: string;
53
+ /**
54
+ * Specifies a boolean for disabling or enabling the primary button. This is important for form validation
55
+ * Returning `true` prevents the primary button from being clicked until required fields are completed.
56
+ */
57
+ disableSubmit?: boolean;
58
+ /**
59
+ * Specifies which DOM element in the form should be focused.
60
+ */
61
+ selectorPrimaryFocus: ReactNode;
62
+ }
1
63
  /**
2
64
  * The `CreateModal` component provides a way for a user to quickly generate a new
3
65
  resource. It is triggered by a user’s action, appears on top of the main page
4
66
  content, and is persistent until dismissed. The purpose of this modal should be
5
67
  immediately apparent to the user, with a clear and obvious path to completion.
6
68
  */
7
- export let CreateModal: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
8
- import React from 'react';
69
+ export declare let CreateModal: React.ForwardRefExoticComponent<CreateModalProps & {
70
+ children?: React.ReactNode;
71
+ } & React.RefAttributes<unknown>>;
72
+ export {};
@@ -28,7 +28,6 @@ var isValidChildren = function isValidChildren() {
28
28
  return;
29
29
  };
30
30
  };
31
-
32
31
  /**
33
32
  * The `CreateModal` component provides a way for a user to quickly generate a new
34
33
  resource. It is triggered by a user’s action, appears on top of the main page
@@ -93,6 +92,7 @@ CreateModal.propTypes = {
93
92
  /**
94
93
  * Children refers to all form items within a form inside of the modal's body.
95
94
  */
95
+ /**@ts-ignore*/
96
96
  children: isValidChildren(),
97
97
  /**
98
98
  * Specify an optional className to be applied to the modal root node
@@ -87,7 +87,7 @@ var DatagridContent = function DatagridContent(_ref) {
87
87
  var renderTable = function renderTable() {
88
88
  var _getTableProps;
89
89
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Table, _extends({}, getTableProps(), {
90
- className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), _defineProperty({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), _defineProperty({}, "".concat(blockClass, "__table-grid-active"), gridActive), _defineProperty({}, "".concat(blockClass, "__table-is-resizing"), typeof columnResizing.isResizingColumn === 'string'), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
90
+ className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), _defineProperty({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), _defineProperty({}, "".concat(blockClass, "__table-grid-active"), gridActive), _defineProperty({}, "".concat(blockClass, "__table-is-resizing"), typeof (columnResizing === null || columnResizing === void 0 ? void 0 : columnResizing.isResizingColumn) === 'string'), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
91
91
  role: withInlineEdit ? 'grid' : undefined,
92
92
  tabIndex: withInlineEdit ? 0 : -1,
93
93
  onKeyDown: /* istanbul ignore next */
@@ -1,5 +1,5 @@
1
1
  export default Columns;
2
- declare function Columns({ getVisibleColumnsCount, filterString, columns, setColumnsObject, onSelectColumn, assistiveTextInstructionsLabel, assistiveTextDisabledInstructionsLabel, selectAllLabel, }: {
2
+ declare function Columns({ getVisibleColumnsCount, filterString, columns, setColumnsObject, onSelectColumn, assistiveTextInstructionsLabel, assistiveTextDisabledInstructionsLabel, selectAllLabel, customizeTearsheetHeadingLabel }: {
3
3
  getVisibleColumnsCount: any;
4
4
  filterString: any;
5
5
  columns: any;
@@ -8,12 +8,14 @@ declare function Columns({ getVisibleColumnsCount, filterString, columns, setCol
8
8
  assistiveTextInstructionsLabel: any;
9
9
  assistiveTextDisabledInstructionsLabel: any;
10
10
  selectAllLabel: any;
11
+ customizeTearsheetHeadingLabel: any;
11
12
  }): import("react/jsx-runtime").JSX.Element;
12
13
  declare namespace Columns {
13
14
  namespace propTypes {
14
15
  let assistiveTextDisabledInstructionsLabel: PropTypes.Requireable<string>;
15
16
  let assistiveTextInstructionsLabel: PropTypes.Requireable<string>;
16
17
  let columns: PropTypes.Validator<any[]>;
18
+ let customizeTearsheetHeadingLabel: PropTypes.Requireable<string>;
17
19
  let disabledInstructionsLabel: PropTypes.Requireable<string>;
18
20
  let filterString: PropTypes.Validator<string>;
19
21
  let getVisibleColumnsCount: PropTypes.Validator<(...args: any[]) => any>;
@@ -24,7 +24,8 @@ var Columns = function Columns(_ref) {
24
24
  onSelectColumn = _ref.onSelectColumn,
25
25
  assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
26
26
  assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
27
- selectAllLabel = _ref.selectAllLabel;
27
+ selectAllLabel = _ref.selectAllLabel,
28
+ customizeTearsheetHeadingLabel = _ref.customizeTearsheetHeadingLabel;
28
29
  var listId = useRef(uuidv4()); // keep id between renders
29
30
  var listRef = useRef(null);
30
31
  var _React$useState = React__default.useState(''),
@@ -47,6 +48,7 @@ var Columns = function Columns(_ref) {
47
48
  }, /*#__PURE__*/React__default.createElement("ol", {
48
49
  className: "".concat(blockClass, "__customize-columns-column-list--focus"),
49
50
  role: "listbox",
51
+ "aria-label": customizeTearsheetHeadingLabel,
50
52
  "aria-describedby": "".concat(blockClass, "__customize-columns--instructions"),
51
53
  tabIndex: 0
52
54
  }, /*#__PURE__*/React__default.createElement("span", {
@@ -81,6 +83,7 @@ Columns.propTypes = {
81
83
  assistiveTextDisabledInstructionsLabel: PropTypes.string,
82
84
  assistiveTextInstructionsLabel: PropTypes.string,
83
85
  columns: PropTypes.array.isRequired,
86
+ customizeTearsheetHeadingLabel: PropTypes.string,
84
87
  disabledInstructionsLabel: PropTypes.string,
85
88
  filterString: PropTypes.string.isRequired,
86
89
  getVisibleColumnsCount: PropTypes.func.isRequired,
@@ -8,7 +8,6 @@
8
8
  import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useState, useCallback, useEffect } from 'react';
10
10
  import PropTypes from '../../../../../node_modules/prop-types/index.js';
11
- import { isColumnVisible } from './common.js';
12
11
  import Columns from './Columns.js';
13
12
  import Actions from './Actions.js';
14
13
  import { pkg } from '../../../../../settings.js';
@@ -51,19 +50,7 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
51
50
  _useState6 = _slicedToArray(_useState5, 2),
52
51
  searchText = _useState6[0],
53
52
  setSearchText = _useState6[1];
54
- var _useState7 = useState(columnDefinitions
55
- // only sort the hidden column to the end when modal reopen
56
- .sort(function (defA, defB) {
57
- var isVisibleA = isColumnVisible(defA);
58
- var isVisibleB = isColumnVisible(defB);
59
- if (isVisibleA && !isVisibleB) {
60
- return -1;
61
- }
62
- if (!isVisibleA && isVisibleB) {
63
- return 1;
64
- }
65
- return 0;
66
- })),
53
+ var _useState7 = useState(columnDefinitions),
67
54
  _useState8 = _slicedToArray(_useState7, 2),
68
55
  columnObjects = _useState8[0],
69
56
  setColumnObjects = _useState8[1];
@@ -149,7 +136,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
149
136
  setColumnObjects(cols);
150
137
  setDirty();
151
138
  },
152
- selectAllLabel: selectAllLabel
139
+ selectAllLabel: selectAllLabel,
140
+ customizeTearsheetHeadingLabel: customizeTearsheetHeadingLabel
153
141
  }));
154
142
  };
155
143
  CustomizeColumnsTearsheet.propTypes = {
@@ -7,13 +7,6 @@
7
7
 
8
8
  import isBoolean from 'lodash/isBoolean';
9
9
 
10
- /*
11
- * Licensed Materials - Property of IBM
12
- * 5724-Q36
13
- * (c) Copyright IBM Corp. 2021
14
- * US Government Users Restricted Rights - Use, duplication or disclosure
15
- * restricted by GSA ADP Schedule Contract with IBM Corp.
16
- */
17
10
  var isColumnVisible = function isColumnVisible(colDef) {
18
11
  return isBoolean(colDef.isVisible) ? colDef.isVisible : true;
19
12
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The Decorator groups a key/value pair to look and behave like a single UI element.
2
+ * The Decorator groups a key/value pair as a single element. This component is not interactive.
3
3
  */
4
4
  export let Decorator: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
5
  import React from 'react';
@@ -5,200 +5,26 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default from 'react';
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
- import cx from 'classnames';
12
11
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
12
+ import { prepareProps } from '../../global/js/utils/props-helper.js';
13
13
  import { pkg } from '../../settings.js';
14
- import { getMagnitude, truncate } from './utils.js';
15
- import { DecoratorIcon } from './DecoratorIcon.js';
14
+ import { DecoratorBase } from '../DecoratorBase/DecoratorBase.js';
16
15
 
17
- var _excluded = ["className", "disabled", "hideIcon", "href", "kind", "label", "setLabelTitle", "onClick", "onClickLabel", "onClickValue", "onContextMenu", "onContextMenuLabel", "onContextMenuValue", "score", "scoreThresholds", "small", "theme", "truncateValue", "value", "valueTitle"];
18
- var blockClass = "".concat(pkg.prefix, "--decorator");
19
16
  var componentName = 'Decorator';
20
- var defaults = {
21
- kind: 'default',
22
- onClick: function onClick() {},
23
- onClickLabel: function onClickLabel() {},
24
- onClickValue: function onClickValue() {},
25
- onContextMenu: function onContextMenu() {},
26
- onContextMenuLabel: function onContextMenuLabel() {},
27
- onContextMenuValue: function onContextMenuValue() {},
28
- scoreThresholds: [0, 4, 7, 10],
29
- theme: 'light'
30
- };
31
17
 
32
18
  /**
33
- * The Decorator groups a key/value pair to look and behave like a single UI element.
19
+ * The Decorator groups a key/value pair as a single element. This component is not interactive.
34
20
  */
35
- var Decorator = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
36
- var className = _ref.className,
37
- disabled = _ref.disabled,
38
- hideIcon = _ref.hideIcon,
39
- href = _ref.href,
40
- _ref$kind = _ref.kind,
41
- kind = _ref$kind === void 0 ? defaults.kind : _ref$kind,
42
- label = _ref.label,
43
- setLabelTitle = _ref.setLabelTitle,
44
- _ref$onClick = _ref.onClick,
45
- onClick = _ref$onClick === void 0 ? defaults.onClick : _ref$onClick,
46
- _ref$onClickLabel = _ref.onClickLabel,
47
- onClickLabel = _ref$onClickLabel === void 0 ? defaults.onClickLabel : _ref$onClickLabel,
48
- _ref$onClickValue = _ref.onClickValue,
49
- onClickValue = _ref$onClickValue === void 0 ? defaults.onClickValue : _ref$onClickValue,
50
- _ref$onContextMenu = _ref.onContextMenu,
51
- onContextMenu = _ref$onContextMenu === void 0 ? defaults.onContextMenu : _ref$onContextMenu,
52
- _ref$onContextMenuLab = _ref.onContextMenuLabel,
53
- onContextMenuLabel = _ref$onContextMenuLab === void 0 ? defaults.onContextMenuLabel : _ref$onContextMenuLab,
54
- _ref$onContextMenuVal = _ref.onContextMenuValue,
55
- onContextMenuValue = _ref$onContextMenuVal === void 0 ? defaults.onContextMenuValue : _ref$onContextMenuVal,
56
- score = _ref.score,
57
- _ref$scoreThresholds = _ref.scoreThresholds,
58
- scoreThresholds = _ref$scoreThresholds === void 0 ? defaults.scoreThresholds : _ref$scoreThresholds,
59
- small = _ref.small,
60
- _ref$theme = _ref.theme,
61
- theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
62
- truncateValue = _ref.truncateValue,
63
- value = _ref.value,
64
- valueTitle = _ref.valueTitle,
65
- rest = _objectWithoutProperties(_ref, _excluded);
66
- var magnitude = getMagnitude(score, scoreThresholds);
67
- var _labelTitle = setLabelTitle && setLabelTitle(score, scoreThresholds, magnitude);
68
- var _value = truncate(value, truncateValue);
69
-
70
- // These class names apply to all types of Decorator.
71
- var classNames = cx(blockClass, className, "".concat(blockClass, "--").concat(theme), _defineProperty(_defineProperty(_defineProperty(_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));
72
-
73
- // These properties apply to all <DecoratorIcons>.
74
- var decoratorIconsProps = {
75
- className: "".concat(blockClass, "__icon"),
76
- magnitude: magnitude.toLowerCase(),
77
- // e.g. "Medium" -> "medium"
78
- small: small
79
- };
80
-
81
- // Optional callback functions if `kind` is "link" or "single-button".
82
- var handleOnClick = function handleOnClick(event) {
83
- onClick(event, {
84
- score: score,
85
- label: label,
86
- value: value,
87
- magnitude: magnitude
88
- });
89
- };
90
- var handleOnContextMenu = function handleOnContextMenu(event) {
91
- onContextMenu(event, {
92
- score: score,
93
- label: label,
94
- value: value,
95
- magnitude: magnitude
96
- });
97
- };
98
-
99
- // RETURN DUAL BUTTONS
100
- if (kind === 'dual-button') {
101
- // Optional callback functions if `kind` is "dual-button" only.
102
- var handleOnClickLabel = function handleOnClickLabel(event) {
103
- onClickLabel(event, {
104
- score: score,
105
- label: label,
106
- value: value,
107
- magnitude: magnitude
108
- });
109
- };
110
- var handleOnClickValue = function handleOnClickValue(event) {
111
- onClickValue(event, {
112
- score: score,
113
- label: label,
114
- value: value,
115
- magnitude: magnitude
116
- });
117
- };
118
- var handleOnContextMenuLabel = function handleOnContextMenuLabel(event) {
119
- onContextMenuLabel(event, {
120
- score: score,
121
- label: label,
122
- value: value,
123
- magnitude: magnitude
124
- });
125
- };
126
- var handleOnContextMenuValue = function handleOnContextMenuValue(event) {
127
- onContextMenuValue(event, {
128
- score: score,
129
- label: label,
130
- value: value,
131
- magnitude: magnitude
132
- });
133
- };
134
- return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, getDevtoolsProps(componentName), {
135
- className: cx(classNames, "".concat(blockClass, "--buttons"), _defineProperty({}, "".concat(blockClass, "-disabled"), disabled)),
136
- ref: ref
137
- }), /*#__PURE__*/React__default.createElement("button", {
138
- className: "".concat(blockClass, "__label"),
139
- disabled: disabled,
140
- onClick: !disabled && handleOnClickLabel,
141
- onContextMenu: !disabled && handleOnContextMenuLabel,
142
- title: _labelTitle || label,
143
- type: "button"
144
- }, !hideIcon && /*#__PURE__*/React__default.createElement(DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default.createElement("button", {
145
- className: "".concat(blockClass, "__value"),
146
- disabled: disabled,
147
- onClick: !disabled && handleOnClickValue,
148
- onContextMenu: !disabled && handleOnContextMenuValue,
149
- title: valueTitle || value,
150
- type: "button"
151
- }, _value));
152
- }
153
-
154
- // RETURN SINGLE BUTTON
155
- if (kind === 'single-button') {
156
- return /*#__PURE__*/React__default.createElement("button", _extends({}, rest, getDevtoolsProps(componentName), {
157
- className: cx(classNames, "".concat(blockClass, "--button"), _defineProperty({}, "".concat(blockClass, "-disabled"), disabled)),
158
- disabled: disabled,
159
- onClick: !disabled && handleOnClick,
160
- onContextMenu: !disabled && handleOnContextMenu,
161
- ref: ref,
162
- type: "button"
163
- }), /*#__PURE__*/React__default.createElement("span", {
164
- className: "".concat(blockClass, "__label"),
165
- title: _labelTitle || label
166
- }, !hideIcon && /*#__PURE__*/React__default.createElement(DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default.createElement("span", {
167
- className: "".concat(blockClass, "__value"),
168
- title: valueTitle || value
169
- }, _value));
170
- }
171
-
172
- // RETURN LINK
173
- if (kind === 'link') {
174
- return /*#__PURE__*/React__default.createElement("a", _extends({}, rest, getDevtoolsProps(componentName), {
175
- href: href,
176
- className: cx(classNames, "".concat(blockClass, "--link")),
177
- onClick: handleOnClick,
178
- onContextMenu: handleOnContextMenu,
179
- ref: ref
180
- }), /*#__PURE__*/React__default.createElement("span", {
181
- className: "".concat(blockClass, "__label"),
182
- title: _labelTitle || label
183
- }, !hideIcon && /*#__PURE__*/React__default.createElement(DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default.createElement("span", {
184
- className: "".concat(blockClass, "__value"),
185
- title: valueTitle || value
186
- }, _value));
187
- }
188
-
189
- // RETURN DEFAULT (NON-INTERACTIVE)
190
- if (kind === 'default') {
191
- return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, getDevtoolsProps(componentName), {
192
- className: cx(classNames, "".concat(blockClass, "--default")),
193
- ref: ref
194
- }), /*#__PURE__*/React__default.createElement("span", {
195
- className: "".concat(blockClass, "__label"),
196
- title: _labelTitle || label
197
- }, !hideIcon && /*#__PURE__*/React__default.createElement(DecoratorIcon, decoratorIconsProps), !!label && label), /*#__PURE__*/React__default.createElement("span", {
198
- className: "".concat(blockClass, "__value"),
199
- title: valueTitle || value
200
- }, _value));
201
- }
21
+ var Decorator = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
22
+ var validProps = prepareProps(props, ['disabled', 'kind', 'onClick', 'onClickLabel', 'onClickValue', 'onContextMenu', 'onContextMenuLabel', 'onContextMenuValue']);
23
+ return /*#__PURE__*/React__default.createElement(DecoratorBase, _extends({
24
+ ref: ref
25
+ }, validProps, {
26
+ kind: "default"
27
+ }, getDevtoolsProps(componentName)));
202
28
  });
203
29
 
204
30
  // Return a placeholder if not released and not enabled by feature flag
@@ -216,70 +42,14 @@ Decorator.propTypes = {
216
42
  * Provide an optional class to be applied to the containing node.
217
43
  */
218
44
  className: PropTypes.string,
219
- /**
220
- * `disabled` only applies if `kind` is "single-button" or "dual-button".
221
- */
222
- disabled: PropTypes.bool,
223
45
  /**
224
46
  * Do not show the icon, regardless of score.
225
47
  */
226
48
  hideIcon: PropTypes.bool,
227
- /**
228
- * `href` is req'd if `kind` is "link".
229
- *
230
- * These two properties together will render the `label` and `value` as a single anchor tag.
231
- */
232
- href: PropTypes.string,
233
- /**
234
- * If `kind` is "dual-button" then refer to the `onClickLabel`, `onClickValue`, `onContextMenuLabel`, and `onContextMenuValue` callback functions.
235
- *
236
- * If `kind` is "single-button" then refer to the `onClick` and `onContextMenu` callback functions.
237
- *
238
- * If `kind` is "link" then also populate `href`.
239
- *
240
- * `kind's` default value is "default" and has no other requirements.
241
- */
242
- kind: PropTypes.oneOf(['default', 'link', 'single-button', 'dual-button']),
243
49
  /**
244
50
  * The label for the data.
245
51
  */
246
52
  label: PropTypes.string,
247
- /**
248
- * Optional callback function if `kind` is "link" or "single-button".
249
- *
250
- * Returns two objects: `event` and `{ score, label, value, magnitude }`
251
- */
252
- onClick: PropTypes.func,
253
- /**
254
- * Optional callback functions if `kind` is "dual-button" only.
255
- *
256
- * Returns two objects: `event` and `{ score, label, value, magnitude }`
257
- */
258
- onClickLabel: PropTypes.func,
259
- /**
260
- * Optional callback functions if `kind` is "dual-button" only.
261
- *
262
- * Returns two objects: `event` and `{ score, label, value, magnitude }`
263
- */
264
- onClickValue: PropTypes.func,
265
- /**
266
- * Optional callback function if `kind` is "link" or "single-button".
267
- *
268
- * Returns two objects: `event` and `{ score, label, value, magnitude }`
269
- */
270
- onContextMenu: PropTypes.func,
271
- /**
272
- * Optional callback functions if `kind` is "dual-button" only.
273
- *
274
- * Returns two objects: `event` and `{ score, label, value, magnitude }`
275
- */
276
- onContextMenuLabel: PropTypes.func,
277
- /**
278
- * Optional callback functions if `kind` is "dual-button" only.
279
- *
280
- * Returns two objects: `event` and `{ score, label, value, magnitude }`
281
- */
282
- onContextMenuValue: PropTypes.func,
283
53
  /**
284
54
  * Used in conjunction with `scoreThresholds`, determines the color, shape, and type of magnitude of the icon.
285
55
  *
@@ -301,13 +71,13 @@ Decorator.propTypes = {
301
71
  */
302
72
  scoreThresholds: PropTypes.arrayOf(PropTypes.number),
303
73
  /**
304
- * Callback function for building the label's descriptive text for screen readers.
74
+ * Optional callback function for building a more detailed descriptive text.
75
+ * Returns `score`, `scoreThresholds`, `magnitude`.
305
76
  *
306
- * The default description is in the form of `"(magnitude)" magnitude: score X out of Y"`.
307
- * E.g. `"Medium" magnitude: score 5 out of 10`.
77
+ * Typical description is in the form of
78
+ * '"(magnitude)" magnitude: score (score) out of (last element of scoreThresholds array)'.
308
79
  *
309
- * Where `magnitude` is the label associated with the specific score,
310
- * X is the `score`, and Y is the last element of the `setLabelTitle` array.
80
+ * E.g. `"Medium" magnitude: score 5 out of 10`.
311
81
  *
312
82
  * If not defined, the title will default to the `label` prop.
313
83
  */
@@ -322,13 +92,6 @@ Decorator.propTypes = {
322
92
  theme: PropTypes.oneOf(['light', 'dark']),
323
93
  /**
324
94
  * If not defined, it will behave as `display:inline-block`.
325
- *
326
- * If `end` it will append "..." to the `value` if there is not enough space.
327
- *
328
- * If `start` it will prepend "..." to the `value` if there is not enough space.
329
- *
330
- * If `{maxLength, front, back}` it will inject "..." in the middle
331
- * of the `value` regardless of available space.
332
95
  */
333
96
  truncateValue: PropTypes.oneOfType([PropTypes.oneOf(['end', 'start']), PropTypes.shape({
334
97
  maxLength: PropTypes.number,
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The DecoratorBase groups a key/value pair to look and behave like a single UI element.
3
+ *
4
+ * DecoratorBase is for internal use only. Refer to the other Decorator types as components for your app.
5
+ */
6
+ export let DecoratorBase: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
7
+ import React from 'react';