@carbon/ibm-products 1.57.0 → 1.59.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/css/index-full-carbon.css +392 -944
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +4 -4
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +346 -900
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +3 -3
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +390 -944
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +4 -4
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/Checklist/Checklist.js +277 -0
  14. package/es/components/Checklist/ChecklistChart.js +98 -0
  15. package/es/components/Checklist/ChecklistIcon.js +105 -0
  16. package/es/components/Checklist/index.js +8 -0
  17. package/es/components/CreateFullPage/CreateFullPage.js +25 -3
  18. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
  19. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +34 -18
  20. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +2 -37
  21. package/es/components/InlineTip/InlineTip.js +5 -1
  22. package/es/components/InlineTip/InlineTipButton.js +1 -8
  23. package/es/components/InlineTip/InlineTipLink.js +1 -8
  24. package/es/components/NonLinearReading/NonLinearReading.js +9 -4
  25. package/es/components/index.js +2 -1
  26. package/es/global/js/package-settings.js +1 -0
  27. package/es/global/js/utils/test-helper.js +2 -2
  28. package/lib/components/Checklist/Checklist.js +267 -0
  29. package/lib/components/Checklist/ChecklistChart.js +88 -0
  30. package/lib/components/Checklist/ChecklistIcon.js +92 -0
  31. package/lib/components/Checklist/index.js +12 -0
  32. package/lib/components/CreateFullPage/CreateFullPage.js +24 -2
  33. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
  34. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +35 -19
  35. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +2 -40
  36. package/lib/components/InlineTip/InlineTip.js +4 -0
  37. package/lib/components/InlineTip/InlineTipButton.js +2 -9
  38. package/lib/components/InlineTip/InlineTipLink.js +2 -9
  39. package/lib/components/NonLinearReading/NonLinearReading.js +8 -3
  40. package/lib/components/index.js +8 -1
  41. package/lib/global/js/package-settings.js +1 -0
  42. package/lib/global/js/utils/test-helper.js +2 -2
  43. package/package.json +10 -10
  44. package/scss/components/Checklist/_checklist.scss +231 -0
  45. package/scss/components/Checklist/_index.scss +8 -0
  46. package/scss/components/Checklist/_storybook-styles.scss +13 -0
  47. package/scss/components/ComboButton/_combo-button.scss +2 -1
  48. package/scss/components/Datagrid/styles/_datagrid.scss +31 -5
  49. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +6 -1
  50. package/scss/components/NonLinearReading/_non-linear-reading.scss +76 -64
  51. package/scss/components/Toolbar/_toolbar.scss +6 -3
  52. package/scss/components/_index.scss +1 -0
@@ -8,9 +8,8 @@
8
8
  * restricted by GSA ADP Schedule Contract with IBM Corp.
9
9
  */
10
10
 
11
- import React, { useEffect } from 'react';
11
+ import React from 'react';
12
12
  import PropTypes from 'prop-types';
13
- import { rem } from '@carbon/layout';
14
13
  import { RadioButtonGroup, RadioButton } from 'carbon-components-react';
15
14
  import isArray from 'lodash/isArray';
16
15
  import { pkg } from '../../../../../settings';
@@ -19,9 +18,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
19
18
  var rowSizes = _ref.rowSizes,
20
19
  selectedOption = _ref.selectedOption,
21
20
  datagridName = _ref.datagridName,
22
- buttonRef = _ref.buttonRef,
23
21
  onChange = _ref.onChange,
24
- hideRadioGroup = _ref.hideRadioGroup,
25
22
  legendText = _ref.legendText,
26
23
  _ref$rowSizeLabels = _ref.rowSizeLabels,
27
24
  rowSizeLabels = _ref$rowSizeLabels === void 0 ? {
@@ -31,25 +28,9 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
31
28
  sm: 'Small',
32
29
  xs: 'Extra small'
33
30
  } : _ref$rowSizeLabels;
34
- var _getDropdownPosition = getDropdownPosition(buttonRef.current),
35
- top = _getDropdownPosition.top,
36
- right = _getDropdownPosition.right;
37
- useEffect(function () {
38
- window.addEventListener('click', hideRadioGroup);
39
- return function () {
40
- window.removeEventListener('click', hideRadioGroup);
41
- };
42
- }, [hideRadioGroup]);
43
31
  return /*#__PURE__*/React.createElement("div", {
44
32
  className: "".concat(blockClass, "__row-size-dropdown"),
45
- style: {
46
- top: rem(top),
47
- right: rem(right)
48
- },
49
- role: "presentation",
50
- onClick: function onClick(e) {
51
- e.stopPropagation();
52
- }
33
+ role: "presentation"
53
34
  }, /*#__PURE__*/React.createElement(RadioButtonGroup, {
54
35
  legendText: legendText,
55
36
  name: "row-height-group",
@@ -83,21 +64,6 @@ var getBackwardCompatibleRowSize = function getBackwardCompatibleRowSize(rowSize
83
64
 
84
65
  return rowSizeMap[rowSize] || rowSize;
85
66
  };
86
- var getDropdownPosition = function getDropdownPosition(buttonEle) {
87
- var parent = buttonEle.parentElement;
88
- if (parent instanceof HTMLElement) {
89
- var top = buttonEle.offsetTop + buttonEle.offsetHeight;
90
- var right = parent.offsetWidth - (buttonEle.offsetLeft + buttonEle.offsetWidth);
91
- return {
92
- top: top,
93
- right: right
94
- };
95
- }
96
- return {
97
- top: 0,
98
- right: 0
99
- };
100
- };
101
67
  RowSizeRadioGroup.defaultProps = {
102
68
  rowSizes: [{
103
69
  value: 'xl' // 64
@@ -116,7 +82,6 @@ RowSizeRadioGroup.defaultProps = {
116
82
  RowSizeRadioGroup.propTypes = {
117
83
  buttonRef: PropTypes.any.isRequired,
118
84
  datagridName: PropTypes.string,
119
- hideRadioGroup: PropTypes.func.isRequired,
120
85
  legendText: PropTypes.string,
121
86
  onChange: PropTypes.func.isRequired,
122
87
  rowSizeLabels: PropTypes.object,
@@ -10,7 +10,7 @@ var _excluded = ["children", "className", "closeIconDescription", "collapsible",
10
10
  */
11
11
 
12
12
  // Import portions of React that are needed.
13
- import React, { useEffect, useMemo, useState } from 'react';
13
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
14
14
 
15
15
  // Other standard imports.
16
16
  import { Close16, Crossroads16, Idea20 } from '@carbon/icons-react';
@@ -20,6 +20,7 @@ import cx from 'classnames';
20
20
  import { getComponentText } from './utils';
21
21
  import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia';
22
22
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
23
+ import uuidv4 from '../../global/js/utils/uuidv4';
23
24
  import { pkg /*, carbon */ } from '../../settings';
24
25
 
25
26
  // Carbon and package components we use.
@@ -79,6 +80,7 @@ export var InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
79
80
  _useState2 = _slicedToArray(_useState, 2),
80
81
  isCollapsed = _useState2[0],
81
82
  setIsCollapsed = _useState2[1];
83
+ var labelId = useRef(uuidv4()).current;
82
84
  var previewText = useMemo(function () {
83
85
  return getComponentText(React.Children.toArray(children));
84
86
  }, [children]);
@@ -94,6 +96,7 @@ export var InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
94
96
  setIsCollapsed(collapsible);
95
97
  }, [collapsible]);
96
98
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
99
+ "aria-labelledby": labelId,
97
100
  className: cx(blockClass,
98
101
  // Apply the block class to the main HTML element
99
102
  className,
@@ -115,6 +118,7 @@ export var InlineTip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
115
118
  }, /*#__PURE__*/React.createElement(Idea20, null)), /*#__PURE__*/React.createElement("div", {
116
119
  className: "".concat(blockClass, "__content")
117
120
  }, /*#__PURE__*/React.createElement("h6", {
121
+ id: labelId,
118
122
  className: "".concat(blockClass, "__title")
119
123
  }, title), /*#__PURE__*/React.createElement("section", {
120
124
  className: "".concat(blockClass, "__body")
@@ -42,7 +42,7 @@ var componentName = 'InlineTipButton';
42
42
  // };
43
43
 
44
44
  /**
45
- * TODO: A description of the component.
45
+ * TODO: A standard Carbon button, styled specifically for use inside InlineTip.
46
46
  */
47
47
  export var InlineTipButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
48
48
  var children = _ref.children,
@@ -65,13 +65,6 @@ export var InlineTipButton = /*#__PURE__*/React.forwardRef(function (_ref, ref)
65
65
  }), children);
66
66
  });
67
67
 
68
- // Return a placeholder if not released and not enabled by feature flag
69
- InlineTipButton = pkg.checkComponentEnabled(InlineTipButton, componentName);
70
-
71
- // The display name of the component, used by React. Note that displayName
72
- // is used in preference to relying on function.name.
73
- InlineTipButton.displayName = componentName;
74
-
75
68
  // The types and DocGen commentary for the component props,
76
69
  // in alphabetical order (for consistency).
77
70
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -43,7 +43,7 @@ var componentName = 'InlineTipLink';
43
43
  // };
44
44
 
45
45
  /**
46
- * TODO: A description of the component.
46
+ * TODO: A standard Carbon link, styled specifically for use inside InlineTip.
47
47
  */
48
48
  export var InlineTipLink = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
49
49
  var children = _ref.children,
@@ -65,13 +65,6 @@ export var InlineTipLink = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
65
65
  }), children);
66
66
  });
67
67
 
68
- // Return a placeholder if not released and not enabled by feature flag
69
- InlineTipLink = pkg.checkComponentEnabled(InlineTipLink, componentName);
70
-
71
- // The display name of the component, used by React. Note that displayName
72
- // is used in preference to relying on function.name.
73
- InlineTipLink.displayName = componentName;
74
-
75
68
  // The types and DocGen commentary for the component props,
76
69
  // in alphabetical order (for consistency).
77
70
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -9,11 +9,12 @@ var _excluded = ["children", "className", "definition", "theme"];
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */
11
11
 
12
- import React, { useState } from 'react';
12
+ import React, { useRef, useState } from 'react';
13
13
  import PropTypes from 'prop-types';
14
14
  import cx from 'classnames';
15
15
  import { ChevronDown16 } from '@carbon/icons-react';
16
16
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
17
+ import uuidv4 from '../../global/js/utils/uuidv4';
17
18
  import { pkg } from '../../settings';
18
19
 
19
20
  // The block part of our conventional BEM class names (blockClass__E--M).
@@ -41,6 +42,7 @@ export var NonLinearReading = /*#__PURE__*/React.forwardRef(function (_ref, ref)
41
42
  _useState2 = _slicedToArray(_useState, 2),
42
43
  isOpen = _useState2[0],
43
44
  setOpen = _useState2[1];
45
+ var contentId = useRef(uuidv4()).current;
44
46
  var handleToggle = function handleToggle() {
45
47
  setOpen(function (prevState) {
46
48
  return !prevState;
@@ -52,12 +54,15 @@ export var NonLinearReading = /*#__PURE__*/React.forwardRef(function (_ref, ref)
52
54
  role: "main"
53
55
  }, getDevtoolsProps(componentName)), ' ', /*#__PURE__*/React.createElement("button", {
54
56
  type: "button",
57
+ "aria-controls": contentId,
55
58
  "aria-expanded": isOpen,
56
59
  className: cx("".concat(blockClass, "__keyword"), [isOpen ? ["".concat(blockClass, "__keyword-open")] : ["".concat(blockClass, "__keyword-closed")]]),
57
60
  onClick: handleToggle
58
- }, children, /*#__PURE__*/React.createElement(ChevronDown16, null)), ' ', isOpen && /*#__PURE__*/React.createElement("span", {
59
- className: "".concat(blockClass, "__body")
60
- }, definition), ' ');
61
+ }, children, /*#__PURE__*/React.createElement(ChevronDown16, null)), ' ', /*#__PURE__*/React.createElement("span", {
62
+ id: contentId,
63
+ className: "".concat(blockClass, "__body"),
64
+ hidden: !isOpen
65
+ }, isOpen && definition), ' ');
61
66
  });
62
67
 
63
68
  // Return a placeholder if not released and not enabled by feature flag
@@ -53,4 +53,5 @@ export { CoachmarkButton } from './CoachmarkButton';
53
53
  export { CoachmarkOverlayElements } from './CoachmarkOverlayElements';
54
54
  export { CoachmarkOverlayElement } from './CoachmarkOverlayElement';
55
55
  export { CoachmarkStack } from './CoachmarkStack';
56
- export { InlineTip } from './InlineTip';
56
+ export { InlineTip } from './InlineTip';
57
+ export { Checklist } from './Checklist';
@@ -75,6 +75,7 @@ var defaults = {
75
75
  InlineTip: false,
76
76
  Guidebanner: false,
77
77
  NonLinearReading: false,
78
+ Checklist: false,
78
79
  Coachmark: false,
79
80
  CoachmarkBeacon: false,
80
81
  CoachmarkButton: false,
@@ -109,7 +109,7 @@ var makeMatcherArray = function makeMatcherArray(args) {
109
109
  * A helper function to enable a test to expect a single call to
110
110
  * console.warn, for example when intentionally using a deprecated prop
111
111
  * or supplying invalid parameters for the purposes of the test.
112
- * @param {string|regex|Function|[]} message the expected parameters for the call to
112
+ * @param {string | regex | Function | []} message the expected parameters for the call to
113
113
  * console.warn, which must be called exactly once. A single string or regex or an
114
114
  * expect matcher can be used to match a single-argument call to console.warn (most common),
115
115
  * while an array of strings and/or regex and/or expect matchers can be used to match a
@@ -220,7 +220,7 @@ export var expectLogging = function expectLogging(_ref2, test) {
220
220
  * A helper function to enable a test to expect a single call to
221
221
  * console.error, for example when intentionally omitting a required prop
222
222
  * or supplying an invalid prop type or value for the purposes of the test.
223
- * @param {string|regex|Function|[]} message the expected parameters for the call to
223
+ * @param {string | regex | Function | []} message the expected parameters for the call to
224
224
  * console.error, which must be called exactly once. A single string or regex or an
225
225
  * expect matcher can be used to match a single-argument call to console.error (most common),
226
226
  * while an array of strings and/or regex and/or expect matchers can be used to match a
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Checklist = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+ var _react = _interopRequireWildcard(require("react"));
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+ var _classnames = _interopRequireDefault(require("classnames"));
16
+ var _devtools = require("../../global/js/utils/devtools");
17
+ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
18
+ var _settings = require("../../settings");
19
+ var _carbonComponentsReact = require("carbon-components-react");
20
+ var _iconsReact = require("@carbon/icons-react");
21
+ var _ChecklistIcon = require("./ChecklistIcon");
22
+ var _ChecklistChart = require("./ChecklistChart");
23
+ var _excluded = ["chartValue", "chartLabel", "checklistAriaLabel", "checklistToggleAriaLabel", "className", "onClickViewAll", "onToggle", "open", "showToggle", "taskLists", "theme", "title", "viewAllLabel"];
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+ // The block part of our conventional BEM class names (blockClass__E--M).
27
+ var blockClass = "".concat(_settings.pkg.prefix, "--checklist");
28
+ var componentName = 'Checklist';
29
+
30
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
31
+
32
+ // Default values can be included here and then assigned to the prop params,
33
+ // e.g. prop = defaults.prop,
34
+ // This gathers default values together neatly and ensures non-primitive
35
+ // values are initialized early to avoid react making unnecessary re-renders.
36
+ // Note that default values are not required for props that are 'required',
37
+ // nor for props where the component can apply undefined values reasonably.
38
+ // Default values should be provided when the component needs to make a choice
39
+ // or assumption when a prop is not supplied.
40
+
41
+ // Default values for props
42
+ var defaults = {
43
+ checklistAriaLabel: 'Checklist',
44
+ checklistToggleAriaLabel: 'Checklist toggle',
45
+ onClickViewAll: function onClickViewAll() {},
46
+ onToggle: function onToggle() {},
47
+ open: true,
48
+ showToggle: true,
49
+ taskLists: [],
50
+ theme: 'light'
51
+ };
52
+
53
+ /**
54
+ * TODO: A description of the component.
55
+ */
56
+ var Checklist = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
57
+ var chartValue = _ref.chartValue,
58
+ chartLabel = _ref.chartLabel,
59
+ _ref$checklistAriaLab = _ref.checklistAriaLabel,
60
+ checklistAriaLabel = _ref$checklistAriaLab === void 0 ? defaults.checklistAriaLabel : _ref$checklistAriaLab,
61
+ _ref$checklistToggleA = _ref.checklistToggleAriaLabel,
62
+ checklistToggleAriaLabel = _ref$checklistToggleA === void 0 ? defaults.checklistToggleAriaLabel : _ref$checklistToggleA,
63
+ className = _ref.className,
64
+ _ref$onClickViewAll = _ref.onClickViewAll,
65
+ onClickViewAll = _ref$onClickViewAll === void 0 ? defaults.onClickViewAll : _ref$onClickViewAll,
66
+ _ref$onToggle = _ref.onToggle,
67
+ onToggle = _ref$onToggle === void 0 ? defaults.onToggle : _ref$onToggle,
68
+ _ref$open = _ref.open,
69
+ open = _ref$open === void 0 ? defaults.open : _ref$open,
70
+ _ref$showToggle = _ref.showToggle,
71
+ showToggle = _ref$showToggle === void 0 ? defaults.showToggle : _ref$showToggle,
72
+ _ref$taskLists = _ref.taskLists,
73
+ taskLists = _ref$taskLists === void 0 ? defaults.taskLists : _ref$taskLists,
74
+ _ref$theme = _ref.theme,
75
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
76
+ title = _ref.title,
77
+ viewAllLabel = _ref.viewAllLabel,
78
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
79
+ var _useState = (0, _react.useState)(open),
80
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
81
+ isOpen = _useState2[0],
82
+ setIsOpen = _useState2[1];
83
+ var listContainerId = (0, _react.useRef)((0, _uuidv.default)()).current;
84
+ var chartLabelId = (0, _react.useRef)((0, _uuidv.default)()).current;
85
+
86
+ // Don't use this test: {chartValue && chartLabel && (render...)}.
87
+ // If `chartValue` is 0 (zero) - a valid value - then it will render 0 and skip the remaining statement.
88
+ // Use this test instead: {chartLabelAndValue && (render...)}.
89
+ // The ChecklistChart component will validate `chartValue`.
90
+ var chartLabelAndValue = typeof chartValue === 'number' && chartLabel;
91
+ var handleClickToggle = function handleClickToggle() {
92
+ setIsOpen(function (prevOpen) {
93
+ return !prevOpen;
94
+ });
95
+ };
96
+ var handleClickViewAll = function handleClickViewAll() {
97
+ onClickViewAll();
98
+ };
99
+
100
+ // If state changes, then trigger callback.
101
+ (0, _react.useEffect)(function () {
102
+ onToggle(isOpen);
103
+ }, [isOpen, onToggle]);
104
+
105
+ // If the "open" prop is changed after initialization,
106
+ // then update internal state.
107
+ (0, _react.useEffect)(function () {
108
+ setIsOpen(open);
109
+ }, [open]);
110
+ return /*#__PURE__*/_react.default.createElement("aside", (0, _extends2.default)({}, rest, {
111
+ "aria-label": checklistAriaLabel,
112
+ className: (0, _classnames.default)(blockClass,
113
+ // Apply the block class to the main HTML element
114
+ className, // Apply any supplied class names to the main HTML element.
115
+ // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
116
+ (0, _defineProperty2.default)({}, "".concat(blockClass, "__closed"), !isOpen)),
117
+ ref: ref
118
+ }, (0, _devtools.getDevtoolsProps)(componentName)), (title || chartLabelAndValue) && /*#__PURE__*/_react.default.createElement("header", {
119
+ className: "".concat(blockClass, "__header")
120
+ }, chartLabelAndValue && /*#__PURE__*/_react.default.createElement(_ChecklistChart.ChecklistChart, {
121
+ "aria-labelledby": chartLabelId,
122
+ theme: theme,
123
+ value: chartValue
124
+ }), /*#__PURE__*/_react.default.createElement("div", {
125
+ className: "".concat(blockClass, "__titles")
126
+ }, title && /*#__PURE__*/_react.default.createElement("h2", {
127
+ className: "".concat(blockClass, "__title")
128
+ }, title), chartLabelAndValue && /*#__PURE__*/_react.default.createElement("h3", {
129
+ id: chartLabelId,
130
+ className: "".concat(blockClass, "__chart-label")
131
+ }, chartLabel)), showToggle && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
132
+ "aria-controls": listContainerId,
133
+ "aria-expanded": isOpen,
134
+ "aria-label": checklistToggleAriaLabel,
135
+ className: "".concat(blockClass, "__toggle"),
136
+ kind: "ghost",
137
+ onClick: handleClickToggle,
138
+ size: "small"
139
+ }, /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronUp16, {
140
+ className: (0, _classnames.default)("".concat(blockClass, "__chevron"))
141
+ }))), /*#__PURE__*/_react.default.createElement("div", {
142
+ id: listContainerId,
143
+ className: "".concat(blockClass, "__content-outer")
144
+ }, /*#__PURE__*/_react.default.createElement("div", {
145
+ className: "".concat(blockClass, "__content-inner")
146
+ }, /*#__PURE__*/_react.default.createElement("section", {
147
+ className: (0, _classnames.default)("".concat(blockClass, "__body"))
148
+ }, taskLists.map(function (list, index) {
149
+ return /*#__PURE__*/_react.default.createElement("div", {
150
+ className: "".concat(blockClass, "__list-group"),
151
+ key: "".concat(list.title, "-").concat(index)
152
+ }, list.title && /*#__PURE__*/_react.default.createElement("h3", {
153
+ title: list.title,
154
+ className: "".concat(blockClass, "__list-title")
155
+ }, list.title), /*#__PURE__*/_react.default.createElement("ol", {
156
+ className: "".concat(blockClass, "__list")
157
+ }, list.tasks.map(function (item, index) {
158
+ return /*#__PURE__*/_react.default.createElement("li", {
159
+ className: "".concat(blockClass, "__list-item"),
160
+ key: "".concat(item.label, "-").concat(index)
161
+ }, /*#__PURE__*/_react.default.createElement(_ChecklistIcon.ChecklistIcon, {
162
+ kind: item.kind
163
+ }), typeof item.onClick === 'function' ? /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
164
+ className: (0, _classnames.default)("".concat(blockClass, "__button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__button--error"), item.kind === 'error')),
165
+ onClick: function onClick() {
166
+ item.onClick(item);
167
+ },
168
+ size: "small"
169
+ }, /*#__PURE__*/_react.default.createElement("div", {
170
+ title: item.label
171
+ }, item.label)) : /*#__PURE__*/_react.default.createElement("span", {
172
+ className: (0, _classnames.default)("".concat(blockClass, "__label"), "".concat(blockClass, "__label--").concat(item.kind)),
173
+ title: item.label
174
+ }, item.label));
175
+ })));
176
+ })), viewAllLabel && /*#__PURE__*/_react.default.createElement("footer", {
177
+ className: "".concat(blockClass, "__footer")
178
+ }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
179
+ className: (0, _classnames.default)("".concat(blockClass, "__button"), "".concat(blockClass, "__view-all")),
180
+ onClick: handleClickViewAll,
181
+ size: "small"
182
+ }, /*#__PURE__*/_react.default.createElement("div", null, viewAllLabel))))));
183
+ });
184
+
185
+ // Return a placeholder if not released and not enabled by feature flag
186
+ exports.Checklist = Checklist;
187
+ exports.Checklist = Checklist = _settings.pkg.checkComponentEnabled(Checklist, componentName);
188
+
189
+ // The display name of the component, used by React. Note that displayName
190
+ // is used in preference to relying on function.name.
191
+ Checklist.displayName = componentName;
192
+
193
+ // The types and DocGen commentary for the component props,
194
+ // in alphabetical order (for consistency).
195
+ // See https://www.npmjs.com/package/prop-types#usage.
196
+ Checklist.propTypes = {
197
+ /**
198
+ * Define both `chartLabel` and `chartValue` to show the chart and its label together.
199
+ */
200
+ chartLabel: _propTypes.default.string,
201
+ /**
202
+ * A number between 0 and 1.
203
+ *
204
+ * Define both `chartLabel` and `chartValue` to show the chart and its label together.
205
+ */
206
+ chartValue: _propTypes.default.number,
207
+ /**
208
+ * Aria-label for the Checklist component.
209
+ */
210
+ checklistAriaLabel: _propTypes.default.string,
211
+ /**
212
+ * Aria-label for the Checklist's toggle component.
213
+ */
214
+ checklistToggleAriaLabel: _propTypes.default.string,
215
+ /**
216
+ * Provide an optional class to be applied to the containing node.
217
+ */
218
+ className: _propTypes.default.string,
219
+ /**
220
+ * Callback for the "View all" button. See also `viewAllLabel`.
221
+ */
222
+ onClickViewAll: _propTypes.default.func,
223
+ /**
224
+ * Optional callback for when the list is opened/closed.
225
+ */
226
+ onToggle: _propTypes.default.func,
227
+ /**
228
+ * Specifies whether the component is opened or closed.
229
+ * This can be set during initialization, or changed after being rendered.
230
+ */
231
+ open: _propTypes.default.bool,
232
+ /**
233
+ * Whether or not to show the open/close toggle.
234
+ */
235
+ showToggle: _propTypes.default.bool,
236
+ /**
237
+ * The task list can be broken down into sub-lists.
238
+ *
239
+ * Each sub-list can include an optional `title`.
240
+ *
241
+ * Each task must specify the appropriate icon (`kind`) and `label`.
242
+ *
243
+ * If any task has an `onClick` callback function defined,
244
+ * then the `label` will be rendered as a button,
245
+ * else the `label` will be rendered as plain text.
246
+ */
247
+ taskLists: _propTypes.default.arrayOf(_propTypes.default.shape({
248
+ title: _propTypes.default.string,
249
+ tasks: _propTypes.default.arrayOf(_propTypes.default.shape({
250
+ kind: _propTypes.default.oneOf(['unchecked', 'indeterminate', 'checked', 'disabled', 'error']).isRequired,
251
+ label: _propTypes.default.string.isRequired,
252
+ onClick: _propTypes.default.func
253
+ })).isRequired
254
+ })).isRequired,
255
+ /**
256
+ * Determines the theme of the component.
257
+ */
258
+ theme: _propTypes.default.oneOf(['light', 'dark']),
259
+ /**
260
+ * The title of the component.
261
+ */
262
+ title: _propTypes.default.string,
263
+ /**
264
+ * If defined, will show and enable the "View all (#)" button at the bottom of the list.
265
+ */
266
+ viewAllLabel: _propTypes.default.string
267
+ };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChecklistChart = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+ var _devtools = require("../../global/js/utils/devtools");
14
+ var _settings = require("../../settings");
15
+ var _clamp = _interopRequireDefault(require("lodash/clamp"));
16
+ var _excluded = ["className", "value", "theme"];
17
+ // Carbon and package components we use.
18
+ /* TODO: @import(s) of carbon components and other package components. */
19
+
20
+ // The block part of our conventional BEM class names (blockClass__E--M).
21
+ var blockClass = "".concat(_settings.pkg.prefix, "--checklist__chart");
22
+ var componentName = 'ChecklistChart';
23
+
24
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
25
+
26
+ // Default values can be included here and then assigned to the prop params,
27
+ // e.g. prop = defaults.prop,
28
+ // This gathers default values together neatly and ensures non-primitive
29
+ // values are initialized early to avoid react making unnecessary re-renders.
30
+ // Note that default values are not required for props that are 'required',
31
+ // nor for props where the component can apply undefined values reasonably.
32
+ // Default values should be provided when the component needs to make a choice
33
+ // or assumption when a prop is not supplied.
34
+
35
+ // Default values for props
36
+ var defaults = {
37
+ theme: 'light'
38
+ };
39
+
40
+ /**
41
+ * TODO: A description of the component.
42
+ */
43
+ var ChecklistChart = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
44
+ var className = _ref.className,
45
+ value = _ref.value,
46
+ _ref$theme = _ref.theme,
47
+ theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
48
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
49
+ var numDegrees = (0, _clamp.default)(value * 360, 0, 360);
50
+ var circleColor = theme === 'light' ? '#c6c6c6' : '#525252'; // $gray-30, $gray-70
51
+ var progressColor = theme === 'light' ? '#6929c4' : '#A56EFF'; // $purple-70, $purple-50
52
+
53
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
54
+ className: (0, _classnames.default)(blockClass, className),
55
+ style: {
56
+ backgroundImage: "conic-gradient(".concat(progressColor, " ").concat(numDegrees, "deg, ").concat(circleColor, " ").concat(numDegrees, "deg 360deg)"),
57
+ borderRadius: '50%'
58
+ },
59
+ ref: ref,
60
+ role: "img"
61
+ }, (0, _devtools.getDevtoolsProps)(componentName)));
62
+ });
63
+
64
+ // Return a placeholder if not released and not enabled by feature flag
65
+ // ChecklistChart = pkg.checkComponentEnabled(ChecklistChart, componentName);
66
+
67
+ // The display name of the component, used by React. Note that displayName
68
+ // is used in preference to relying on function.name.
69
+ // ChecklistChart.displayName = componentName;
70
+
71
+ // The types and DocGen commentary for the component props,
72
+ // in alphabetical order (for consistency).
73
+ // See https://www.npmjs.com/package/prop-types#usage.
74
+ exports.ChecklistChart = ChecklistChart;
75
+ ChecklistChart.propTypes = {
76
+ /**
77
+ * Optional class name for this component.
78
+ */
79
+ className: _propTypes.default.string,
80
+ /**
81
+ * Determines the theme of the component.
82
+ */
83
+ theme: _propTypes.default.oneOf(['light', 'dark']),
84
+ /**
85
+ * Number between 0 and 1.
86
+ */
87
+ value: _propTypes.default.number.isRequired
88
+ };