@carbon/ibm-products 1.56.0 → 1.58.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +392 -895
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +392 -895
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +392 -895
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/Checklist/Checklist.js +277 -0
- package/es/components/Checklist/ChecklistChart.js +104 -0
- package/es/components/Checklist/ChecklistIcon.js +105 -0
- package/es/components/Checklist/index.js +8 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +12 -7
- package/es/components/Datagrid/Datagrid/DatagridContent.js +6 -3
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +128 -7
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +1 -23
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +111 -0
- package/es/components/Datagrid/useDatagrid.js +5 -2
- package/es/components/Datagrid/utils/getColTitle.js +25 -0
- package/es/components/NonLinearReading/NonLinearReading.js +9 -4
- package/es/components/index.js +2 -1
- package/es/global/js/hooks/useResizeObserver.js +19 -3
- package/es/global/js/package-settings.js +1 -0
- package/lib/components/Checklist/Checklist.js +267 -0
- package/lib/components/Checklist/ChecklistChart.js +94 -0
- package/lib/components/Checklist/ChecklistIcon.js +92 -0
- package/lib/components/Checklist/index.js +12 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -7
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +6 -3
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +131 -7
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +4 -26
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +122 -0
- package/lib/components/Datagrid/useDatagrid.js +5 -2
- package/lib/components/Datagrid/utils/getColTitle.js +32 -0
- package/lib/components/NonLinearReading/NonLinearReading.js +8 -3
- package/lib/components/index.js +8 -1
- package/lib/global/js/hooks/useResizeObserver.js +19 -3
- package/lib/global/js/package-settings.js +1 -0
- package/package.json +2 -2
- package/scss/components/Checklist/_checklist.scss +231 -0
- package/scss/components/Checklist/_index.scss +8 -0
- package/scss/components/Checklist/_storybook-styles.scss +13 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +91 -0
- package/scss/components/NonLinearReading/_non-linear-reading.scss +76 -64
- package/scss/components/_index.scss +1 -0
@@ -0,0 +1,277 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
+
var _excluded = ["chartValue", "chartLabel", "checklistAriaLabel", "checklistToggleAriaLabel", "className", "onClickViewAll", "onToggle", "open", "showToggle", "taskLists", "theme", "title", "viewAllLabel"];
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2023, 2023
|
8
|
+
*
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* TODO: Breakdown titles, icons, clickable items into sub-components
|
15
|
+
* See
|
16
|
+
* ModifiedTabs (ModifiedTabLabelNew, ModifiedTabLabelWithClose)
|
17
|
+
* PageHeader (PageHeaderTitle, PageHeaderUtils)
|
18
|
+
*/
|
19
|
+
|
20
|
+
// Import portions of React that are needed.
|
21
|
+
import React, { useEffect, useRef, useState } from 'react';
|
22
|
+
|
23
|
+
// Other standard imports.
|
24
|
+
import PropTypes from 'prop-types';
|
25
|
+
import cx from 'classnames';
|
26
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
27
|
+
import uuidv4 from '../../global/js/utils/uuidv4';
|
28
|
+
import { pkg /*, carbon */ } from '../../settings';
|
29
|
+
|
30
|
+
// Carbon and package components we use.
|
31
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
32
|
+
import { Button } from 'carbon-components-react';
|
33
|
+
import { ChevronUp16 } from '@carbon/icons-react';
|
34
|
+
import { ChecklistIcon } from './ChecklistIcon';
|
35
|
+
import { ChecklistChart } from './ChecklistChart';
|
36
|
+
|
37
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
38
|
+
var blockClass = "".concat(pkg.prefix, "--checklist");
|
39
|
+
var componentName = 'Checklist';
|
40
|
+
|
41
|
+
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
42
|
+
|
43
|
+
// Default values can be included here and then assigned to the prop params,
|
44
|
+
// e.g. prop = defaults.prop,
|
45
|
+
// This gathers default values together neatly and ensures non-primitive
|
46
|
+
// values are initialized early to avoid react making unnecessary re-renders.
|
47
|
+
// Note that default values are not required for props that are 'required',
|
48
|
+
// nor for props where the component can apply undefined values reasonably.
|
49
|
+
// Default values should be provided when the component needs to make a choice
|
50
|
+
// or assumption when a prop is not supplied.
|
51
|
+
|
52
|
+
// Default values for props
|
53
|
+
var defaults = {
|
54
|
+
checklistAriaLabel: 'Checklist',
|
55
|
+
checklistToggleAriaLabel: 'Checklist toggle',
|
56
|
+
onClickViewAll: function onClickViewAll() {},
|
57
|
+
onToggle: function onToggle() {},
|
58
|
+
open: true,
|
59
|
+
showToggle: true,
|
60
|
+
taskLists: [],
|
61
|
+
theme: 'light'
|
62
|
+
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* TODO: A description of the component.
|
66
|
+
*/
|
67
|
+
export var Checklist = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
68
|
+
var chartValue = _ref.chartValue,
|
69
|
+
chartLabel = _ref.chartLabel,
|
70
|
+
_ref$checklistAriaLab = _ref.checklistAriaLabel,
|
71
|
+
checklistAriaLabel = _ref$checklistAriaLab === void 0 ? defaults.checklistAriaLabel : _ref$checklistAriaLab,
|
72
|
+
_ref$checklistToggleA = _ref.checklistToggleAriaLabel,
|
73
|
+
checklistToggleAriaLabel = _ref$checklistToggleA === void 0 ? defaults.checklistToggleAriaLabel : _ref$checklistToggleA,
|
74
|
+
className = _ref.className,
|
75
|
+
_ref$onClickViewAll = _ref.onClickViewAll,
|
76
|
+
onClickViewAll = _ref$onClickViewAll === void 0 ? defaults.onClickViewAll : _ref$onClickViewAll,
|
77
|
+
_ref$onToggle = _ref.onToggle,
|
78
|
+
onToggle = _ref$onToggle === void 0 ? defaults.onToggle : _ref$onToggle,
|
79
|
+
_ref$open = _ref.open,
|
80
|
+
open = _ref$open === void 0 ? defaults.open : _ref$open,
|
81
|
+
_ref$showToggle = _ref.showToggle,
|
82
|
+
showToggle = _ref$showToggle === void 0 ? defaults.showToggle : _ref$showToggle,
|
83
|
+
_ref$taskLists = _ref.taskLists,
|
84
|
+
taskLists = _ref$taskLists === void 0 ? defaults.taskLists : _ref$taskLists,
|
85
|
+
_ref$theme = _ref.theme,
|
86
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
87
|
+
title = _ref.title,
|
88
|
+
viewAllLabel = _ref.viewAllLabel,
|
89
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
90
|
+
var _useState = useState(open),
|
91
|
+
_useState2 = _slicedToArray(_useState, 2),
|
92
|
+
isOpen = _useState2[0],
|
93
|
+
setIsOpen = _useState2[1];
|
94
|
+
var listContainerId = useRef(uuidv4()).current;
|
95
|
+
var chartLabelId = useRef(uuidv4()).current;
|
96
|
+
|
97
|
+
// Don't use this test: {chartValue && chartLabel && (render...)}.
|
98
|
+
// If `chartValue` is 0 (zero) - a valid value - then it will render 0 and skip the remaining statement.
|
99
|
+
// Use this test instead: {chartLabelAndValue && (render...)}.
|
100
|
+
// The ChecklistChart component will validate `chartValue`.
|
101
|
+
var chartLabelAndValue = typeof chartValue === 'number' && chartLabel;
|
102
|
+
var handleClickToggle = function handleClickToggle() {
|
103
|
+
setIsOpen(function (prevOpen) {
|
104
|
+
return !prevOpen;
|
105
|
+
});
|
106
|
+
};
|
107
|
+
var handleClickViewAll = function handleClickViewAll() {
|
108
|
+
onClickViewAll();
|
109
|
+
};
|
110
|
+
|
111
|
+
// If state changes, then trigger callback.
|
112
|
+
useEffect(function () {
|
113
|
+
onToggle(isOpen);
|
114
|
+
}, [isOpen, onToggle]);
|
115
|
+
|
116
|
+
// If the "open" prop is changed after initialization,
|
117
|
+
// then update internal state.
|
118
|
+
useEffect(function () {
|
119
|
+
setIsOpen(open);
|
120
|
+
}, [open]);
|
121
|
+
return /*#__PURE__*/React.createElement("aside", _extends({}, rest, {
|
122
|
+
"aria-label": checklistAriaLabel,
|
123
|
+
className: cx(blockClass,
|
124
|
+
// Apply the block class to the main HTML element
|
125
|
+
className, // Apply any supplied class names to the main HTML element.
|
126
|
+
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
|
127
|
+
_defineProperty({}, "".concat(blockClass, "__closed"), !isOpen)),
|
128
|
+
ref: ref
|
129
|
+
}, getDevtoolsProps(componentName)), (title || chartLabelAndValue) && /*#__PURE__*/React.createElement("header", {
|
130
|
+
className: "".concat(blockClass, "__header")
|
131
|
+
}, chartLabelAndValue && /*#__PURE__*/React.createElement(ChecklistChart, {
|
132
|
+
ariaLabelledById: chartLabelId,
|
133
|
+
value: chartValue,
|
134
|
+
theme: theme
|
135
|
+
}), /*#__PURE__*/React.createElement("div", {
|
136
|
+
className: "".concat(blockClass, "__titles")
|
137
|
+
}, title && /*#__PURE__*/React.createElement("h2", {
|
138
|
+
className: "".concat(blockClass, "__title")
|
139
|
+
}, title), chartLabelAndValue && /*#__PURE__*/React.createElement("h3", {
|
140
|
+
id: chartLabelId,
|
141
|
+
className: "".concat(blockClass, "__chart-label")
|
142
|
+
}, chartLabel)), showToggle && /*#__PURE__*/React.createElement(Button, {
|
143
|
+
"aria-controls": listContainerId,
|
144
|
+
"aria-expanded": isOpen,
|
145
|
+
"aria-label": checklistToggleAriaLabel,
|
146
|
+
className: "".concat(blockClass, "__toggle"),
|
147
|
+
kind: "ghost",
|
148
|
+
onClick: handleClickToggle,
|
149
|
+
size: "small"
|
150
|
+
}, /*#__PURE__*/React.createElement(ChevronUp16, {
|
151
|
+
className: cx("".concat(blockClass, "__chevron"))
|
152
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
153
|
+
id: listContainerId,
|
154
|
+
className: "".concat(blockClass, "__content-outer")
|
155
|
+
}, /*#__PURE__*/React.createElement("div", {
|
156
|
+
className: "".concat(blockClass, "__content-inner")
|
157
|
+
}, /*#__PURE__*/React.createElement("section", {
|
158
|
+
className: cx("".concat(blockClass, "__body"))
|
159
|
+
}, taskLists.map(function (list, index) {
|
160
|
+
return /*#__PURE__*/React.createElement("div", {
|
161
|
+
className: "".concat(blockClass, "__list-group"),
|
162
|
+
key: "".concat(list.title, "-").concat(index)
|
163
|
+
}, list.title && /*#__PURE__*/React.createElement("h3", {
|
164
|
+
title: list.title,
|
165
|
+
className: "".concat(blockClass, "__list-title")
|
166
|
+
}, list.title), /*#__PURE__*/React.createElement("ol", {
|
167
|
+
className: "".concat(blockClass, "__list")
|
168
|
+
}, list.tasks.map(function (item, index) {
|
169
|
+
return /*#__PURE__*/React.createElement("li", {
|
170
|
+
className: "".concat(blockClass, "__list-item"),
|
171
|
+
key: "".concat(item.label, "-").concat(index)
|
172
|
+
}, /*#__PURE__*/React.createElement(ChecklistIcon, {
|
173
|
+
kind: item.kind
|
174
|
+
}), typeof item.onClick === 'function' ? /*#__PURE__*/React.createElement(Button, {
|
175
|
+
className: cx("".concat(blockClass, "__button"), _defineProperty({}, "".concat(blockClass, "__button--error"), item.kind === 'error')),
|
176
|
+
onClick: function onClick() {
|
177
|
+
item.onClick(item);
|
178
|
+
},
|
179
|
+
size: "small"
|
180
|
+
}, /*#__PURE__*/React.createElement("div", {
|
181
|
+
title: item.label
|
182
|
+
}, item.label)) : /*#__PURE__*/React.createElement("span", {
|
183
|
+
className: cx("".concat(blockClass, "__label"), "".concat(blockClass, "__label--").concat(item.kind)),
|
184
|
+
title: item.label
|
185
|
+
}, item.label));
|
186
|
+
})));
|
187
|
+
})), viewAllLabel && /*#__PURE__*/React.createElement("footer", {
|
188
|
+
className: "".concat(blockClass, "__footer")
|
189
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
190
|
+
className: cx("".concat(blockClass, "__button"), "".concat(blockClass, "__view-all")),
|
191
|
+
onClick: handleClickViewAll,
|
192
|
+
size: "small"
|
193
|
+
}, /*#__PURE__*/React.createElement("div", null, viewAllLabel))))));
|
194
|
+
});
|
195
|
+
|
196
|
+
// Return a placeholder if not released and not enabled by feature flag
|
197
|
+
Checklist = pkg.checkComponentEnabled(Checklist, componentName);
|
198
|
+
|
199
|
+
// The display name of the component, used by React. Note that displayName
|
200
|
+
// is used in preference to relying on function.name.
|
201
|
+
Checklist.displayName = componentName;
|
202
|
+
|
203
|
+
// The types and DocGen commentary for the component props,
|
204
|
+
// in alphabetical order (for consistency).
|
205
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
206
|
+
Checklist.propTypes = {
|
207
|
+
/**
|
208
|
+
* Define both `chartLabel` and `chartValue` to show the chart and its label together.
|
209
|
+
*/
|
210
|
+
chartLabel: PropTypes.string,
|
211
|
+
/**
|
212
|
+
* A number between 0 and 1.
|
213
|
+
*
|
214
|
+
* Define both `chartLabel` and `chartValue` to show the chart and its label together.
|
215
|
+
*/
|
216
|
+
chartValue: PropTypes.number,
|
217
|
+
/**
|
218
|
+
* Aria-label for the Checklist component.
|
219
|
+
*/
|
220
|
+
checklistAriaLabel: PropTypes.string,
|
221
|
+
/**
|
222
|
+
* Aria-label for the Checklist's toggle component.
|
223
|
+
*/
|
224
|
+
checklistToggleAriaLabel: PropTypes.string,
|
225
|
+
/**
|
226
|
+
* Provide an optional class to be applied to the containing node.
|
227
|
+
*/
|
228
|
+
className: PropTypes.string,
|
229
|
+
/**
|
230
|
+
* Callback for the "View all" button. See also `viewAllLabel`.
|
231
|
+
*/
|
232
|
+
onClickViewAll: PropTypes.func,
|
233
|
+
/**
|
234
|
+
* Optional callback for when the list is opened/closed.
|
235
|
+
*/
|
236
|
+
onToggle: PropTypes.func,
|
237
|
+
/**
|
238
|
+
* Specifies whether the component is opened or closed.
|
239
|
+
* This can be set during initialization, or changed after being rendered.
|
240
|
+
*/
|
241
|
+
open: PropTypes.bool,
|
242
|
+
/**
|
243
|
+
* Whether or not to show the open/close toggle.
|
244
|
+
*/
|
245
|
+
showToggle: PropTypes.bool,
|
246
|
+
/**
|
247
|
+
* The task list can be broken down into sub-lists.
|
248
|
+
*
|
249
|
+
* Each sub-list can include an optional `title`.
|
250
|
+
*
|
251
|
+
* Each task must specify the appropriate icon (`kind`) and `label`.
|
252
|
+
*
|
253
|
+
* If any task has an `onClick` callback function defined,
|
254
|
+
* then the `label` will be rendered as a button,
|
255
|
+
* else the `label` will be rendered as plain text.
|
256
|
+
*/
|
257
|
+
taskLists: PropTypes.arrayOf(PropTypes.shape({
|
258
|
+
title: PropTypes.string,
|
259
|
+
tasks: PropTypes.arrayOf(PropTypes.shape({
|
260
|
+
kind: PropTypes.oneOf(['unchecked', 'indeterminate', 'checked', 'disabled', 'error']).isRequired,
|
261
|
+
label: PropTypes.string.isRequired,
|
262
|
+
onClick: PropTypes.func
|
263
|
+
})).isRequired
|
264
|
+
})).isRequired,
|
265
|
+
/**
|
266
|
+
* Determines the theme of the component.
|
267
|
+
*/
|
268
|
+
theme: PropTypes.oneOf(['light', 'dark']),
|
269
|
+
/**
|
270
|
+
* The title of the component.
|
271
|
+
*/
|
272
|
+
title: PropTypes.string,
|
273
|
+
/**
|
274
|
+
* If defined, will show and enable the "View all (#)" button at the bottom of the list.
|
275
|
+
*/
|
276
|
+
viewAllLabel: PropTypes.string
|
277
|
+
};
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["className", "ariaLabelledById", "value", "theme"];
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2023, 2023
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* TODO: Breakdown titles, icons, clickable items into sub-components
|
13
|
+
* See
|
14
|
+
* ModifiedTabs (ModifiedTabLabelNew, ModifiedTabLabelWithClose)
|
15
|
+
* PageHeader (PageHeaderTitle, PageHeaderUtils)
|
16
|
+
*/
|
17
|
+
|
18
|
+
// Import portions of React that are needed.
|
19
|
+
import React from 'react';
|
20
|
+
|
21
|
+
// Other standard imports.
|
22
|
+
import PropTypes from 'prop-types';
|
23
|
+
import cx from 'classnames';
|
24
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
25
|
+
import { pkg /*, carbon */ } from '../../settings';
|
26
|
+
import clamp from 'lodash/clamp';
|
27
|
+
|
28
|
+
// Carbon and package components we use.
|
29
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
30
|
+
|
31
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
32
|
+
var blockClass = "".concat(pkg.prefix, "--checklist__chart");
|
33
|
+
var componentName = 'ChecklistChart';
|
34
|
+
|
35
|
+
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
36
|
+
|
37
|
+
// Default values can be included here and then assigned to the prop params,
|
38
|
+
// e.g. prop = defaults.prop,
|
39
|
+
// This gathers default values together neatly and ensures non-primitive
|
40
|
+
// values are initialized early to avoid react making unnecessary re-renders.
|
41
|
+
// Note that default values are not required for props that are 'required',
|
42
|
+
// nor for props where the component can apply undefined values reasonably.
|
43
|
+
// Default values should be provided when the component needs to make a choice
|
44
|
+
// or assumption when a prop is not supplied.
|
45
|
+
|
46
|
+
// Default values for props
|
47
|
+
var defaults = {
|
48
|
+
theme: 'light'
|
49
|
+
};
|
50
|
+
|
51
|
+
/**
|
52
|
+
* TODO: A description of the component.
|
53
|
+
*/
|
54
|
+
export var ChecklistChart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
55
|
+
var className = _ref.className,
|
56
|
+
ariaLabelledById = _ref.ariaLabelledById,
|
57
|
+
value = _ref.value,
|
58
|
+
_ref$theme = _ref.theme,
|
59
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
60
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
61
|
+
var numDegrees = clamp(value * 360, 0, 360);
|
62
|
+
var circleColor = theme === 'light' ? '#c6c6c6' : '#525252'; // $gray-30, $gray-70
|
63
|
+
var progressColor = theme === 'light' ? '#6929c4' : '#A56EFF'; // $purple-70, $purple-50
|
64
|
+
|
65
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
66
|
+
"aria-labelledby": ariaLabelledById,
|
67
|
+
className: cx(blockClass, className),
|
68
|
+
style: {
|
69
|
+
backgroundImage: "conic-gradient(".concat(progressColor, " ").concat(numDegrees, "deg, ").concat(circleColor, " ").concat(numDegrees, "deg 360deg)"),
|
70
|
+
borderRadius: '50%'
|
71
|
+
},
|
72
|
+
ref: ref,
|
73
|
+
role: "img"
|
74
|
+
}, getDevtoolsProps(componentName)));
|
75
|
+
});
|
76
|
+
|
77
|
+
// Return a placeholder if not released and not enabled by feature flag
|
78
|
+
// ChecklistChart = pkg.checkComponentEnabled(ChecklistChart, componentName);
|
79
|
+
|
80
|
+
// The display name of the component, used by React. Note that displayName
|
81
|
+
// is used in preference to relying on function.name.
|
82
|
+
// ChecklistChart.displayName = componentName;
|
83
|
+
|
84
|
+
// The types and DocGen commentary for the component props,
|
85
|
+
// in alphabetical order (for consistency).
|
86
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
87
|
+
ChecklistChart.propTypes = {
|
88
|
+
/**
|
89
|
+
* Id of the parent's aria-label for accessibility.
|
90
|
+
*/
|
91
|
+
ariaLabelledById: PropTypes.string.isRequired,
|
92
|
+
/**
|
93
|
+
* Optional class name for this component.
|
94
|
+
*/
|
95
|
+
className: PropTypes.string,
|
96
|
+
/**
|
97
|
+
* Determines the theme of the component.
|
98
|
+
*/
|
99
|
+
theme: PropTypes.oneOf(['light', 'dark']),
|
100
|
+
/**
|
101
|
+
* Number between 0 and 1.
|
102
|
+
*/
|
103
|
+
value: PropTypes.number.isRequired
|
104
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["className", "kind", "theme"];
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2023, 2023
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* TODO: Breakdown titles, icons, clickable items into sub-components
|
13
|
+
* See
|
14
|
+
* ModifiedTabs (ModifiedTabLabelNew, ModifiedTabLabelWithClose)
|
15
|
+
* PageHeader (PageHeaderTitle, PageHeaderUtils)
|
16
|
+
*/
|
17
|
+
|
18
|
+
// Import portions of React that are needed.
|
19
|
+
import React from 'react';
|
20
|
+
|
21
|
+
// Other standard imports.
|
22
|
+
import PropTypes from 'prop-types';
|
23
|
+
import cx from 'classnames';
|
24
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
25
|
+
import { pkg /*, carbon */ } from '../../settings';
|
26
|
+
|
27
|
+
// Carbon and package components we use.
|
28
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
29
|
+
import { CheckmarkOutline16, CircleDash16, Incomplete16, Warning16 } from '@carbon/icons-react';
|
30
|
+
|
31
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
32
|
+
var blockClass = "".concat(pkg.prefix, "--checklist__icon");
|
33
|
+
var componentName = 'ChecklistIcon';
|
34
|
+
|
35
|
+
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
36
|
+
|
37
|
+
// Default values can be included here and then assigned to the prop params,
|
38
|
+
// e.g. prop = defaults.prop,
|
39
|
+
// This gathers default values together neatly and ensures non-primitive
|
40
|
+
// values are initialized early to avoid react making unnecessary re-renders.
|
41
|
+
// Note that default values are not required for props that are 'required',
|
42
|
+
// nor for props where the component can apply undefined values reasonably.
|
43
|
+
// Default values should be provided when the component needs to make a choice
|
44
|
+
// or assumption when a prop is not supplied.
|
45
|
+
|
46
|
+
// Default values for props
|
47
|
+
var defaults = {
|
48
|
+
theme: 'light'
|
49
|
+
};
|
50
|
+
|
51
|
+
/**
|
52
|
+
* TODO: A description of the component.
|
53
|
+
*/
|
54
|
+
export var ChecklistIcon = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
55
|
+
var className = _ref.className,
|
56
|
+
kind = _ref.kind,
|
57
|
+
_ref$theme = _ref.theme,
|
58
|
+
theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
|
59
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
60
|
+
var Icon;
|
61
|
+
switch (kind) {
|
62
|
+
case 'error':
|
63
|
+
Icon = Warning16;
|
64
|
+
break;
|
65
|
+
case 'indeterminate':
|
66
|
+
Icon = Incomplete16;
|
67
|
+
break;
|
68
|
+
case 'checked':
|
69
|
+
Icon = CheckmarkOutline16;
|
70
|
+
break;
|
71
|
+
default:
|
72
|
+
// "unchecked" or "disabled"
|
73
|
+
Icon = CircleDash16;
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
|
77
|
+
className: cx(blockClass, className, "".concat(blockClass, "--").concat(kind), "".concat(blockClass, "__").concat(theme)),
|
78
|
+
ref: ref
|
79
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(Icon, null));
|
80
|
+
});
|
81
|
+
|
82
|
+
// Return a placeholder if not released and not enabled by feature flag
|
83
|
+
// ChecklistIcon = pkg.checkComponentEnabled(ChecklistIcon, componentName);
|
84
|
+
|
85
|
+
// The display name of the component, used by React. Note that displayName
|
86
|
+
// is used in preference to relying on function.name.
|
87
|
+
// ChecklistIcon.displayName = componentName;
|
88
|
+
|
89
|
+
// The types and DocGen commentary for the component props,
|
90
|
+
// in alphabetical order (for consistency).
|
91
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
92
|
+
ChecklistIcon.propTypes = {
|
93
|
+
/**
|
94
|
+
* Provide an optional class to be applied to the containing node.
|
95
|
+
*/
|
96
|
+
className: PropTypes.string,
|
97
|
+
/**
|
98
|
+
* The icon to be displayed.
|
99
|
+
*/
|
100
|
+
kind: PropTypes.oneOf(['unchecked', 'indeterminate', 'checked', 'disabled', 'error']),
|
101
|
+
/**
|
102
|
+
* Determines the theme of the component.
|
103
|
+
*/
|
104
|
+
theme: PropTypes.oneOf(['light', 'dark'])
|
105
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
var _excluded = ["datagridState"];
|
3
|
+
var _excluded = ["datagridState", "title"];
|
4
4
|
/**
|
5
5
|
* Copyright IBM Corp. 2020, 2022
|
6
6
|
*
|
@@ -21,6 +21,7 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
21
21
|
var componentName = 'Datagrid';
|
22
22
|
export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
23
23
|
var datagridState = _ref.datagridState,
|
24
|
+
title = _ref.title,
|
24
25
|
rest = _objectWithoutProperties(_ref, _excluded);
|
25
26
|
if (!datagridState) {
|
26
27
|
pconsole.warn('Datagrid was not passed datagridState which is required to render this component.');
|
@@ -34,6 +35,10 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
34
35
|
className = datagridState.className,
|
35
36
|
filters = datagridState.state.filters;
|
36
37
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
38
|
+
var props = {
|
39
|
+
title: title,
|
40
|
+
datagridState: datagridState
|
41
|
+
};
|
37
42
|
return /*#__PURE__*/React.createElement(FilterProvider, {
|
38
43
|
filters: filters
|
39
44
|
}, /*#__PURE__*/React.createElement(InlineEditProvider, null, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
@@ -42,11 +47,7 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
42
47
|
className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"), !isFetching && rows.length === 0 ? "".concat(blockClass, "__empty-state") : '')
|
43
48
|
}, getDevtoolsProps(componentName)), (filterProps === null || filterProps === void 0 ? void 0 : filterProps.variation) === 'panel' ? /*#__PURE__*/React.createElement("div", {
|
44
49
|
className: "".concat(blockClass, "__datagridWithPanel ").concat(blockClass, "__displayFlex ").concat(blockClass, "__leftPanel-position")
|
45
|
-
}, /*#__PURE__*/React.createElement(DatagridContent,
|
46
|
-
datagridState: datagridState
|
47
|
-
})) : /*#__PURE__*/React.createElement(DatagridContent, {
|
48
|
-
datagridState: datagridState
|
49
|
-
}))));
|
50
|
+
}, /*#__PURE__*/React.createElement(DatagridContent, props)) : /*#__PURE__*/React.createElement(DatagridContent, props))));
|
50
51
|
});
|
51
52
|
|
52
53
|
// Return a placeholder if not released and not enabled by feature flag
|
@@ -59,5 +60,9 @@ Datagrid.propTypes = {
|
|
59
60
|
/**
|
60
61
|
* The data grid state, much of it being supplied by the useDatagrid hook
|
61
62
|
*/
|
62
|
-
datagridState: PropTypes.object.isRequired
|
63
|
+
datagridState: PropTypes.object.isRequired,
|
64
|
+
/**
|
65
|
+
* Table title
|
66
|
+
*/
|
67
|
+
title: PropTypes.string
|
63
68
|
};
|
@@ -30,7 +30,8 @@ var TableContainer = DataTable.TableContainer,
|
|
30
30
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
31
31
|
export var DatagridContent = function DatagridContent(_ref) {
|
32
32
|
var _cx4;
|
33
|
-
var datagridState = _ref.datagridState
|
33
|
+
var datagridState = _ref.datagridState,
|
34
|
+
title = _ref.title;
|
34
35
|
var _useContext = useContext(InlineEditContext),
|
35
36
|
inlineEditState = _useContext.state,
|
36
37
|
dispatch = _useContext.dispatch;
|
@@ -98,7 +99,8 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
98
99
|
} : null,
|
99
100
|
onFocus: withInlineEdit ? function () {
|
100
101
|
return handleGridFocus(inlineEditState, dispatch);
|
101
|
-
} : null
|
102
|
+
} : null,
|
103
|
+
title: title
|
102
104
|
}), !withVirtualScroll ? /*#__PURE__*/React.createElement(DatagridHead, datagridState) : null, /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
103
105
|
rows: rows
|
104
106
|
})));
|
@@ -180,5 +182,6 @@ DatagridContent.propTypes = {
|
|
180
182
|
setAllFilters: PropTypes.func,
|
181
183
|
getFilterProps: PropTypes.func,
|
182
184
|
state: PropTypes.object
|
183
|
-
})
|
185
|
+
}),
|
186
|
+
title: PropTypes.string
|
184
187
|
};
|