@carbon/ibm-products 1.55.2 → 1.57.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +640 -0
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +640 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +640 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/Carousel/Carousel.js +15 -5
- package/es/components/Coachmark/Coachmark.js +243 -0
- package/es/components/Coachmark/CoachmarkDragbar.js +137 -0
- package/es/components/Coachmark/CoachmarkHeader.js +88 -0
- package/es/components/Coachmark/CoachmarkOverlay.js +139 -0
- package/es/components/Coachmark/CoachmarkTagline.js +93 -0
- package/es/components/Coachmark/index.js +10 -0
- package/es/components/Coachmark/utils/constants.js +76 -0
- package/es/components/Coachmark/utils/context.js +5 -0
- package/es/components/Coachmark/utils/enums.js +40 -0
- package/es/components/Coachmark/utils/helpers.js +11 -0
- package/es/components/Coachmark/utils/hooks.js +54 -0
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +90 -0
- package/es/components/CoachmarkBeacon/index.js +8 -0
- package/es/components/CoachmarkButton/CoachmarkButton.js +72 -0
- package/es/components/CoachmarkButton/index.js +8 -0
- package/es/components/CoachmarkFixed/CoachmarkFixed.js +201 -0
- package/es/components/CoachmarkFixed/index.js +8 -0
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +86 -0
- package/es/components/CoachmarkOverlayElement/index.js +8 -0
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +175 -0
- package/es/components/CoachmarkOverlayElements/index.js +8 -0
- package/es/components/CoachmarkStack/CoachmarkStack.js +260 -0
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +157 -0
- package/es/components/CoachmarkStack/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 +127 -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/NotificationsPanel/NotificationsPanel.js +3 -2
- package/es/components/index.js +7 -0
- package/es/global/js/hooks/useResizeObserver.js +19 -3
- package/es/global/js/package-settings.js +8 -1
- package/lib/components/Carousel/Carousel.js +15 -5
- package/lib/components/Coachmark/Coachmark.js +247 -0
- package/lib/components/Coachmark/CoachmarkDragbar.js +137 -0
- package/lib/components/Coachmark/CoachmarkHeader.js +85 -0
- package/lib/components/Coachmark/CoachmarkOverlay.js +139 -0
- package/lib/components/Coachmark/CoachmarkTagline.js +90 -0
- package/lib/components/Coachmark/index.js +38 -0
- package/lib/components/Coachmark/utils/constants.js +82 -0
- package/lib/components/Coachmark/utils/context.js +13 -0
- package/lib/components/Coachmark/utils/enums.js +49 -0
- package/lib/components/Coachmark/utils/helpers.js +17 -0
- package/lib/components/Coachmark/utils/hooks.js +60 -0
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +87 -0
- package/lib/components/CoachmarkBeacon/index.js +12 -0
- package/lib/components/CoachmarkButton/CoachmarkButton.js +69 -0
- package/lib/components/CoachmarkButton/index.js +12 -0
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +201 -0
- package/lib/components/CoachmarkFixed/index.js +12 -0
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +83 -0
- package/lib/components/CoachmarkOverlayElement/index.js +12 -0
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +176 -0
- package/lib/components/CoachmarkOverlayElements/index.js +12 -0
- package/lib/components/CoachmarkStack/CoachmarkStack.js +264 -0
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +160 -0
- package/lib/components/CoachmarkStack/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 +130 -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/NotificationsPanel/NotificationsPanel.js +3 -2
- package/lib/components/index.js +49 -0
- package/lib/global/js/hooks/useResizeObserver.js +19 -3
- package/lib/global/js/package-settings.js +8 -1
- package/package.json +2 -2
- package/scss/components/Carousel/_carousel.scss +3 -0
- package/scss/components/Coachmark/_index.scss +11 -0
- package/scss/components/Coachmark/_storybook-styles.scss +20 -0
- package/scss/components/Coachmark/styles/_coachmark-dragbar.scss +74 -0
- package/scss/components/Coachmark/styles/_coachmark-header.scss +58 -0
- package/scss/components/Coachmark/styles/_coachmark-overlay.scss +327 -0
- package/scss/components/Coachmark/styles/_coachmark-tagline.scss +118 -0
- package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +166 -0
- package/scss/components/CoachmarkBeacon/_index.scss +8 -0
- package/scss/components/CoachmarkBeacon/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkButton/_coachmark-button.scss +34 -0
- package/scss/components/CoachmarkButton/_index.scss +8 -0
- package/scss/components/CoachmarkButton/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkFixed/_coachmark-fixed.scss +34 -0
- package/scss/components/CoachmarkFixed/_index.scss +8 -0
- package/scss/components/CoachmarkFixed/_storybook-styles.scss +10 -0
- package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +50 -0
- package/scss/components/CoachmarkOverlayElement/_index.scss +8 -0
- package/scss/components/CoachmarkOverlayElement/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +40 -0
- package/scss/components/CoachmarkOverlayElements/_index.scss +8 -0
- package/scss/components/CoachmarkOverlayElements/_storybook-styles.scss +19 -0
- package/scss/components/CoachmarkStack/_coachmark-stack.scss +85 -0
- package/scss/components/CoachmarkStack/_index.scss +8 -0
- package/scss/components/CoachmarkStack/_storybook-styles.scss +10 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +65 -0
- package/scss/components/_index.scss +7 -1
@@ -0,0 +1,157 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["className", "description", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
|
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
|
+
import React, { forwardRef } from 'react';
|
12
|
+
import pconsole from '../../global/js/utils/pconsole';
|
13
|
+
import PropTypes from 'prop-types';
|
14
|
+
import cx from 'classnames';
|
15
|
+
import { Idea20 } from '@carbon/icons-react';
|
16
|
+
import { Button } from 'carbon-components-react';
|
17
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
18
|
+
import { pkg /*, carbon */ } from '../../settings';
|
19
|
+
import { createPortal } from 'react-dom';
|
20
|
+
import { CoachmarkHeader } from '../Coachmark/CoachmarkHeader';
|
21
|
+
import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia';
|
22
|
+
|
23
|
+
// Carbon and package components we use.
|
24
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
25
|
+
|
26
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
27
|
+
var blockClass = "".concat(pkg.prefix, "--coachmark-stacked-home");
|
28
|
+
var overlayClass = "".concat(pkg.prefix, "--coachmark-overlay");
|
29
|
+
var componentName = 'CoachmarkStackHome';
|
30
|
+
|
31
|
+
/**
|
32
|
+
* DO NOT USE. This component is for the exclusive use
|
33
|
+
* of other Novice to Pro components.
|
34
|
+
*/
|
35
|
+
export var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
36
|
+
var _document$querySelect;
|
37
|
+
var className = _ref.className,
|
38
|
+
description = _ref.description,
|
39
|
+
media = _ref.media,
|
40
|
+
navLinkLabels = _ref.navLinkLabels,
|
41
|
+
onClickNavItem = _ref.onClickNavItem,
|
42
|
+
onClose = _ref.onClose,
|
43
|
+
portalTarget = _ref.portalTarget,
|
44
|
+
closeButtonLabel = _ref.closeButtonLabel,
|
45
|
+
title = _ref.title,
|
46
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
47
|
+
if (!navLinkLabels) {
|
48
|
+
return pconsole.warn("".concat(componentName, " is a Novice to Pro internal component and is not intended for general use."));
|
49
|
+
}
|
50
|
+
var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
|
51
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
52
|
+
className: cx(blockClass, className),
|
53
|
+
ref: ref,
|
54
|
+
role: "main"
|
55
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(CoachmarkHeader, {
|
56
|
+
onClose: onClose
|
57
|
+
}), /*#__PURE__*/React.createElement("div", {
|
58
|
+
className: "".concat(overlayClass, "__body")
|
59
|
+
}, /*#__PURE__*/React.createElement("div", {
|
60
|
+
className: "".concat(overlayClass, "-element")
|
61
|
+
}, !media && /*#__PURE__*/React.createElement(Idea20, {
|
62
|
+
className: "".concat(blockClass, "__icon-idea")
|
63
|
+
}), media && (media.render ? media.render() : /*#__PURE__*/React.createElement(SteppedAnimatedMedia, {
|
64
|
+
className: "".concat(overlayClass, "__element-stepped-media"),
|
65
|
+
filePaths: media.filePaths,
|
66
|
+
playStep: 0
|
67
|
+
})), /*#__PURE__*/React.createElement("div", {
|
68
|
+
className: "".concat(overlayClass, "-element__content")
|
69
|
+
}, title && /*#__PURE__*/React.createElement("h2", {
|
70
|
+
className: "".concat(overlayClass, "-element__title")
|
71
|
+
}, title), description && /*#__PURE__*/React.createElement("p", {
|
72
|
+
className: "".concat(overlayClass, "-element__body")
|
73
|
+
}, description)), /*#__PURE__*/React.createElement("ul", {
|
74
|
+
className: "".concat(blockClass, "__nav-links")
|
75
|
+
}, navLinkLabels.map(function (label, index) {
|
76
|
+
return /*#__PURE__*/React.createElement("li", {
|
77
|
+
key: index
|
78
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
79
|
+
kind: "ghost",
|
80
|
+
size: "sm",
|
81
|
+
onClick: function onClick() {
|
82
|
+
onClickNavItem(index + 1);
|
83
|
+
}
|
84
|
+
}, label));
|
85
|
+
})), closeButtonLabel && /*#__PURE__*/React.createElement("div", {
|
86
|
+
className: "".concat(overlayClass, "__footer")
|
87
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
88
|
+
size: "sm",
|
89
|
+
onClick: onClose
|
90
|
+
}, closeButtonLabel))))), portalNode);
|
91
|
+
});
|
92
|
+
|
93
|
+
// Return a placeholder if not released and not enabled by feature flag
|
94
|
+
CoachmarkStackHome = pkg.checkComponentEnabled(CoachmarkStackHome, componentName);
|
95
|
+
|
96
|
+
// The display name of the component, used by React. Note that displayName
|
97
|
+
// is used in preference to relying on function.name.
|
98
|
+
CoachmarkStackHome.displayName = componentName;
|
99
|
+
|
100
|
+
// The types and DocGen commentary for the component props,
|
101
|
+
// in alphabetical order (for consistency).
|
102
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
103
|
+
CoachmarkStackHome.propTypes = {
|
104
|
+
/**
|
105
|
+
* Optional class name for this component.
|
106
|
+
*/
|
107
|
+
className: PropTypes.string,
|
108
|
+
/**
|
109
|
+
* The label for the button that will close the stack
|
110
|
+
*/
|
111
|
+
closeButtonLabel: PropTypes.string,
|
112
|
+
/**
|
113
|
+
* The description of the Coachmark.
|
114
|
+
*/
|
115
|
+
description: PropTypes.node.isRequired,
|
116
|
+
/**
|
117
|
+
* The object describing an image in one of two shapes.
|
118
|
+
*
|
119
|
+
* If a single media element is required, use `{render}`.
|
120
|
+
*
|
121
|
+
* If a stepped animation is required, use `{filePaths}`.
|
122
|
+
*
|
123
|
+
* @see {@link MEDIA_PROP_TYPE}.
|
124
|
+
*/
|
125
|
+
media: PropTypes.oneOfType([PropTypes.shape({
|
126
|
+
render: PropTypes.func
|
127
|
+
}), PropTypes.shape({
|
128
|
+
filePaths: PropTypes.arrayOf(PropTypes.string)
|
129
|
+
})]),
|
130
|
+
/**
|
131
|
+
* The labels used to link to the stackable Coachmarks.
|
132
|
+
*/
|
133
|
+
navLinkLabels: PropTypes.arrayOf(PropTypes.string).isRequired,
|
134
|
+
/**
|
135
|
+
* For internal use only by CoachmarkStack and CoachmarkStackHome.
|
136
|
+
*/
|
137
|
+
onClickNavItem: PropTypes.func.isRequired,
|
138
|
+
/**
|
139
|
+
* Function to call when the stack closes.
|
140
|
+
*/
|
141
|
+
onClose: PropTypes.func.isRequired,
|
142
|
+
/**
|
143
|
+
* By default, the CoachmarkStackHome will be appended to the end of `document.body`.
|
144
|
+
* The CoachmarkStackHome will remain persistent as the user navigates the app until
|
145
|
+
* the user closes the CoachmarkStackHome.
|
146
|
+
*
|
147
|
+
* Alternatively, the app developer can tightly couple the CoachmarkStackHome to a DOM
|
148
|
+
* element or other component by specifying a CSS selector. The CoachmarkStackHome will
|
149
|
+
* remain visible as long as that element remains visible or mounted. When the
|
150
|
+
* element is hidden or component is unmounted, the CoachmarkStackHome will disappear.
|
151
|
+
*/
|
152
|
+
portalTarget: PropTypes.string,
|
153
|
+
/**
|
154
|
+
* The title of the Coachmark.
|
155
|
+
*/
|
156
|
+
title: PropTypes.string.isRequired
|
157
|
+
};
|
@@ -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
|
};
|
@@ -1,29 +1,103 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
4
|
/**
|
4
|
-
* Copyright IBM Corp. 2020,
|
5
|
+
* Copyright IBM Corp. 2020, 2023
|
5
6
|
*
|
6
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
7
8
|
* LICENSE file in the root directory of this source tree.
|
8
9
|
*/
|
9
10
|
|
10
11
|
// @flow
|
11
|
-
import React from 'react';
|
12
|
+
import React, { useState, useEffect } from 'react';
|
12
13
|
import cx from 'classnames';
|
13
14
|
import { DataTable } from 'carbon-components-react';
|
15
|
+
import { px } from '@carbon/layout';
|
14
16
|
import { selectionColumnId } from '../common-column-ids';
|
15
17
|
import { pkg } from '../../../settings';
|
18
|
+
import { handleColumnResizeEndEvent, handleColumnResizeStartEvent, handleColumnResizingEvent } from './addons/stateReducer';
|
19
|
+
import getColTitle from '../utils/getColTitle';
|
16
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
|
+
var getAccessibilityProps = function getAccessibilityProps(header) {
|
22
|
+
var props = {};
|
23
|
+
var title = getColTitle(header);
|
24
|
+
if (title) {
|
25
|
+
props.title = title;
|
26
|
+
} else {
|
27
|
+
props['aria-hidden'] = true;
|
28
|
+
}
|
29
|
+
return props;
|
30
|
+
};
|
17
31
|
var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
32
|
+
// Used to measure the height of the table and uses that value
|
33
|
+
// to display a vertical line to indicate the column you are resizing
|
34
|
+
useEffect(function () {
|
35
|
+
var tableId = datagridState.tableId;
|
36
|
+
if (tableId) {
|
37
|
+
var gridElement = document.querySelector("#".concat(tableId));
|
38
|
+
var tableElement = gridElement.querySelector('table');
|
39
|
+
var headerRowElement = document.querySelector("#".concat(tableId, " .").concat(blockClass, "__head"));
|
40
|
+
var hasHorizontalScrollbar = tableElement.scrollWidth > tableElement.clientWidth;
|
41
|
+
var scrollBuffer = hasHorizontalScrollbar ? 18 : 2;
|
42
|
+
var tableToolbar = gridElement.querySelector(".".concat(blockClass, "__table-toolbar"));
|
43
|
+
var tableToolbarHeight = (tableToolbar === null || tableToolbar === void 0 ? void 0 : tableToolbar.offsetHeight) || 0;
|
44
|
+
var setCustomValues = function setCustomValues(_ref) {
|
45
|
+
var _ref$rowHeight = _ref.rowHeight,
|
46
|
+
rowHeight = _ref$rowHeight === void 0 ? 48 : _ref$rowHeight,
|
47
|
+
gridHeight = _ref.gridHeight;
|
48
|
+
headerRowElement.style.setProperty("--".concat(blockClass, "--row-height"), px(rowHeight));
|
49
|
+
headerRowElement.style.setProperty("--".concat(blockClass, "--grid-height"), px(gridHeight - scrollBuffer - tableToolbarHeight));
|
50
|
+
};
|
51
|
+
setCustomValues({
|
52
|
+
gridHeight: gridElement.offsetHeight,
|
53
|
+
rowHeight: headerRowElement.clientHeight
|
54
|
+
});
|
55
|
+
}
|
56
|
+
}, [datagridState.rowSize, datagridState.tableId, datagridState]);
|
57
|
+
var _useState = useState(2),
|
58
|
+
_useState2 = _slicedToArray(_useState, 1),
|
59
|
+
incrementAmount = _useState2[0];
|
60
|
+
var getClientXPosition = function getClientXPosition(event) {
|
61
|
+
var isTouchEvent = false;
|
62
|
+
if (event.type === 'touchstart') {
|
63
|
+
// Do not respond to multiple touches (e.g. 2 or 3 fingers)
|
64
|
+
if (event.touches && event.touches.length > 1) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
isTouchEvent = true;
|
68
|
+
}
|
69
|
+
var clientX = isTouchEvent ? Math.round(event.touches[0].clientX) : event.clientX;
|
70
|
+
var closestHeader = event.target.closest('th');
|
71
|
+
var closestHeaderCoords = closestHeader.getBoundingClientRect();
|
72
|
+
var headerOffset = closestHeaderCoords.left;
|
73
|
+
var offsetValue = clientX - headerOffset;
|
74
|
+
return offsetValue;
|
75
|
+
};
|
76
|
+
useEffect(function () {
|
77
|
+
var isResizing = datagridState.state.isResizing;
|
78
|
+
if (isResizing) {
|
79
|
+
var onColResizeEnd = datagridState.onColResizeEnd;
|
80
|
+
document.addEventListener('mouseup', function () {
|
81
|
+
handleColumnResizeEndEvent(datagridState.dispatch, onColResizeEnd, isResizing);
|
82
|
+
document.activeElement.blur();
|
83
|
+
});
|
84
|
+
}
|
85
|
+
return function () {
|
86
|
+
document.removeEventListener('mouseup', function () {
|
87
|
+
return handleColumnResizeEndEvent(datagridState.dispatch);
|
88
|
+
});
|
89
|
+
};
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
91
|
+
}, [datagridState.state.isResizing]);
|
18
92
|
return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps({
|
19
93
|
role: false
|
20
94
|
}), {
|
21
95
|
className: cx("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
|
22
96
|
ref: headRef
|
23
|
-
}), datagridState.headers.filter(function (
|
24
|
-
var isVisible =
|
97
|
+
}), datagridState.headers.filter(function (_ref2) {
|
98
|
+
var isVisible = _ref2.isVisible;
|
25
99
|
return isVisible;
|
26
|
-
}).map(function (header) {
|
100
|
+
}).map(function (header, index) {
|
27
101
|
var _cx;
|
28
102
|
if (header.id === selectionColumnId) {
|
29
103
|
// render directly without the wrapper TableHeader
|
@@ -31,13 +105,59 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
31
105
|
key: header.id
|
32
106
|
});
|
33
107
|
}
|
108
|
+
var _ref3 = header || 50,
|
109
|
+
minWidth = _ref3.minWidth;
|
110
|
+
var visibleColumns = datagridState.visibleColumns,
|
111
|
+
state = datagridState.state,
|
112
|
+
dispatch = datagridState.dispatch,
|
113
|
+
onColResizeEnd = datagridState.onColResizeEnd;
|
114
|
+
var columnResizing = state.columnResizing,
|
115
|
+
isResizing = state.isResizing;
|
116
|
+
var columnWidths = columnResizing.columnWidths;
|
117
|
+
var originalCol = visibleColumns[index];
|
34
118
|
return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps({
|
35
119
|
role: false
|
36
120
|
}), {
|
37
121
|
className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
|
38
122
|
key: header.id
|
39
|
-
}), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("
|
40
|
-
|
123
|
+
}, getAccessibilityProps(header)), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", _extends({}, header.getResizerProps(), {
|
124
|
+
onMouseMove: function onMouseMove(event) {
|
125
|
+
if (isResizing) {
|
126
|
+
var newWidth = getClientXPosition(event);
|
127
|
+
// Sets a min width for resizing so at least one character from the column header is visible
|
128
|
+
if (newWidth >= 50) {
|
129
|
+
handleColumnResizingEvent(dispatch, header, newWidth);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
},
|
133
|
+
onMouseDown: function onMouseDown() {
|
134
|
+
return handleColumnResizeStartEvent(dispatch, header.id);
|
135
|
+
},
|
136
|
+
onKeyDown: function onKeyDown(event) {
|
137
|
+
var key = event.key;
|
138
|
+
if (key === 'ArrowLeft' || key === 'ArrowRight') {
|
139
|
+
var currentColumnWidth = columnWidths[header.id] || (datagridState.isTableSortable && originalCol.width < 90 ? 90 : originalCol.width);
|
140
|
+
if (key === 'ArrowLeft') {
|
141
|
+
if (currentColumnWidth - incrementAmount > Math.max(minWidth, 50)) {
|
142
|
+
var newWidth = currentColumnWidth - incrementAmount;
|
143
|
+
handleColumnResizingEvent(dispatch, header, newWidth, true);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
if (key === 'ArrowRight') {
|
147
|
+
var _newWidth = currentColumnWidth + incrementAmount;
|
148
|
+
handleColumnResizingEvent(dispatch, header, _newWidth, true);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
},
|
152
|
+
onKeyUp: function onKeyUp() {
|
153
|
+
return handleColumnResizeEndEvent(dispatch, onColResizeEnd, header.id);
|
154
|
+
},
|
155
|
+
className: cx("".concat(blockClass, "__col-resizer-range")),
|
156
|
+
type: "range",
|
157
|
+
defaultValue: originalCol.width,
|
158
|
+
"aria-label": "Resize column"
|
159
|
+
})), /*#__PURE__*/React.createElement("span", {
|
160
|
+
className: "".concat(blockClass, "__col-resize-indicator")
|
41
161
|
})));
|
42
162
|
}));
|
43
163
|
};
|
@@ -11,6 +11,7 @@ import { Checkbox } from 'carbon-components-react';
|
|
11
11
|
import { isColumnVisible } from './common';
|
12
12
|
import DraggableElement from '../../DraggableElement';
|
13
13
|
import { pkg } from '../../../../../settings';
|
14
|
+
import getColTitle from '../../../utils/getColTitle';
|
14
15
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
15
16
|
export var DraggableItemsList = function DraggableItemsList(_ref) {
|
16
17
|
var columns = _ref.columns,
|
@@ -22,29 +23,6 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
22
23
|
setAriaRegionText = _ref.setAriaRegionText,
|
23
24
|
setColumnsObject = _ref.setColumnsObject,
|
24
25
|
setFocusIndex = _ref.setFocusIndex;
|
25
|
-
// This function recursively looks for the nested header element until we can find the key which contains the title.
|
26
|
-
// This can happen if multiple hooks are used together that manipulate the rendering of the column
|
27
|
-
// header, such as `useColumnCenterAlign` and `useSortableColumns`.
|
28
|
-
var getNestedTitle = function getNestedTitle(component) {
|
29
|
-
if (component && !component.key) {
|
30
|
-
return getNestedTitle(component.children);
|
31
|
-
}
|
32
|
-
if (component && component.key && typeof component.key === 'string') {
|
33
|
-
return component.key;
|
34
|
-
}
|
35
|
-
};
|
36
|
-
var getColTitle = function getColTitle(col) {
|
37
|
-
if (!col) {
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
var checkTitle = function checkTitle() {
|
41
|
-
if (col.Header().props.children.props && col.Header().props.children.props.title) {
|
42
|
-
return col.Header().props.children.props.title;
|
43
|
-
}
|
44
|
-
return getNestedTitle(col.Header().props.children.props);
|
45
|
-
};
|
46
|
-
return typeof (col === null || col === void 0 ? void 0 : col.Header) === 'function' ? checkTitle() : col.Header.props.title;
|
47
|
-
};
|
48
26
|
return /*#__PURE__*/React.createElement(React.Fragment, null, columns
|
49
27
|
// hide the columns without Header, e.g the sticky actions, spacer
|
50
28
|
.filter(function (colDef) {
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2023, 2023
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
10
|
+
*/
|
11
|
+
|
12
|
+
var COLUMN_RESIZE_START = 'columnStartResizing';
|
13
|
+
var COLUMN_RESIZING = 'columnResizing';
|
14
|
+
var COLUMN_RESIZE_END = 'columnDoneResizing';
|
15
|
+
var INIT = 'init';
|
16
|
+
export var handleColumnResizeStartEvent = function handleColumnResizeStartEvent(dispatch, headerId) {
|
17
|
+
dispatch({
|
18
|
+
type: COLUMN_RESIZE_START,
|
19
|
+
payload: {
|
20
|
+
headerId: headerId
|
21
|
+
}
|
22
|
+
});
|
23
|
+
};
|
24
|
+
export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId) {
|
25
|
+
dispatch({
|
26
|
+
type: COLUMN_RESIZE_END,
|
27
|
+
payload: {
|
28
|
+
onColResizeEnd: onColResizeEnd,
|
29
|
+
headerId: headerId
|
30
|
+
}
|
31
|
+
});
|
32
|
+
};
|
33
|
+
export var handleColumnResizingEvent = function handleColumnResizingEvent(dispatch, header, newWidth, isKeyEvent) {
|
34
|
+
if (isKeyEvent) {
|
35
|
+
dispatch({
|
36
|
+
type: COLUMN_RESIZE_START,
|
37
|
+
payload: {
|
38
|
+
newWidth: newWidth,
|
39
|
+
headerId: header.id,
|
40
|
+
defaultWidth: header.originalWidth
|
41
|
+
}
|
42
|
+
});
|
43
|
+
}
|
44
|
+
dispatch({
|
45
|
+
type: COLUMN_RESIZING,
|
46
|
+
payload: {
|
47
|
+
newWidth: newWidth,
|
48
|
+
headerId: header.id,
|
49
|
+
defaultWidth: header.originalWidth
|
50
|
+
}
|
51
|
+
});
|
52
|
+
};
|
53
|
+
export var stateReducer = function stateReducer(newState, action) {
|
54
|
+
switch (action.type) {
|
55
|
+
case INIT:
|
56
|
+
{
|
57
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
58
|
+
isResizing: false
|
59
|
+
});
|
60
|
+
}
|
61
|
+
case COLUMN_RESIZE_START:
|
62
|
+
{
|
63
|
+
var headerId = action.payload.headerId;
|
64
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
65
|
+
isResizing: headerId
|
66
|
+
});
|
67
|
+
}
|
68
|
+
case COLUMN_RESIZING:
|
69
|
+
{
|
70
|
+
var _ref = action.payload || {},
|
71
|
+
_headerId = _ref.headerId,
|
72
|
+
newWidth = _ref.newWidth,
|
73
|
+
defaultWidth = _ref.defaultWidth;
|
74
|
+
var newColumnWidth = {};
|
75
|
+
if (typeof _headerId === 'undefined') {
|
76
|
+
return _objectSpread({}, newState);
|
77
|
+
}
|
78
|
+
newColumnWidth[_headerId] = newWidth;
|
79
|
+
var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref2) {
|
80
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
81
|
+
_ = _ref3[0],
|
82
|
+
value = _ref3[1];
|
83
|
+
return !isNaN(value);
|
84
|
+
}));
|
85
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
86
|
+
isResizing: _headerId,
|
87
|
+
columnResizing: _objectSpread(_objectSpread({}, newState.columnResizing), {}, {
|
88
|
+
columnWidth: defaultWidth,
|
89
|
+
columnWidths: _objectSpread(_objectSpread({}, cleanedWidths), newColumnWidth),
|
90
|
+
headerIdWidths: [_headerId, newWidth]
|
91
|
+
})
|
92
|
+
});
|
93
|
+
}
|
94
|
+
case COLUMN_RESIZE_END:
|
95
|
+
{
|
96
|
+
var _action$payload = action.payload,
|
97
|
+
onColResizeEnd = _action$payload.onColResizeEnd,
|
98
|
+
_headerId2 = _action$payload.headerId;
|
99
|
+
var currentColumn = {};
|
100
|
+
currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
|
101
|
+
var allChangedColumns = newState.columnResizing.columnWidths;
|
102
|
+
var isResizing = newState.isResizing;
|
103
|
+
if (isResizing) {
|
104
|
+
onColResizeEnd === null || onColResizeEnd === void 0 ? void 0 : onColResizeEnd(currentColumn, allChangedColumns);
|
105
|
+
}
|
106
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
107
|
+
isResizing: false
|
108
|
+
});
|
109
|
+
}
|
110
|
+
}
|
111
|
+
};
|
@@ -19,6 +19,7 @@ import useRowSize from './useRowSize';
|
|
19
19
|
import useHeaderRow from './Datagrid/DatagridHeaderRow';
|
20
20
|
import useFlexResize from './useFlexResize';
|
21
21
|
import useFloatingScroll from './useFloatingScroll';
|
22
|
+
import { stateReducer } from './Datagrid/addons/stateReducer';
|
22
23
|
var useDatagrid = function useDatagrid(params) {
|
23
24
|
var defaultPlugins = [useFlexLayout, useHeaderRow, useSkeletonRows, useResizeColumns, useRowRenderer, useDefaultStringRenderer, useRowSize, useFilters, useGlobalFilter, useSortBy, useExpanded];
|
24
25
|
var defaultEndPlugins = [usePagination, useRowSelect, useFlexResize, useFloatingScroll];
|
@@ -29,9 +30,11 @@ var useDatagrid = function useDatagrid(params) {
|
|
29
30
|
for (var _len = arguments.length, plugins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
30
31
|
plugins[_key - 1] = arguments[_key];
|
31
32
|
}
|
32
|
-
var tableState = useTable.apply(void 0, [_objectSpread({
|
33
|
+
var tableState = useTable.apply(void 0, [_objectSpread(_objectSpread({
|
33
34
|
tableId: tableId
|
34
|
-
}, params)
|
35
|
+
}, params), {}, {
|
36
|
+
stateReducer: stateReducer
|
37
|
+
})].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
|
35
38
|
return tableState;
|
36
39
|
};
|
37
40
|
export default useDatagrid;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// This function recursively looks for the nested header element until we can find the key which contains the title.
|
2
|
+
// This can happen if multiple hooks are used together that manipulate the rendering of the column
|
3
|
+
// header, such as `useColumnCenterAlign` and `useSortableColumns`.
|
4
|
+
var getNestedTitle = function getNestedTitle(component) {
|
5
|
+
if (component && !component.key) {
|
6
|
+
return getNestedTitle(component.children);
|
7
|
+
}
|
8
|
+
if (component && component.key && typeof component.key === 'string') {
|
9
|
+
return component.key;
|
10
|
+
}
|
11
|
+
};
|
12
|
+
var getColTitle = function getColTitle(col) {
|
13
|
+
var _col$Header, _col$Header$props;
|
14
|
+
if (!col) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
var checkTitle = function checkTitle() {
|
18
|
+
if (col.Header().props.children.props && col.Header().props.children.props.title) {
|
19
|
+
return col.Header().props.children.props.title;
|
20
|
+
}
|
21
|
+
return getNestedTitle(col.Header().props.children.props);
|
22
|
+
};
|
23
|
+
return typeof (col === null || col === void 0 ? void 0 : col.Header) === 'function' ? checkTitle() : col === null || col === void 0 ? void 0 : (_col$Header = col.Header) === null || _col$Header === void 0 ? void 0 : (_col$Header$props = _col$Header.props) === null || _col$Header$props === void 0 ? void 0 : _col$Header$props.title;
|
24
|
+
};
|
25
|
+
export default getColTitle;
|
@@ -20,6 +20,7 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
|
20
20
|
import { useClickOutside } from '../../global/js/hooks';
|
21
21
|
import { pkg } from '../../settings';
|
22
22
|
import { timeAgo } from './utils';
|
23
|
+
import { prepareProps } from '../../global/js/utils/props-helper';
|
23
24
|
import { NotificationsEmptyState } from '../EmptyStates/NotificationsEmptyState';
|
24
25
|
|
25
26
|
// Carbon and package components we use.
|
@@ -289,10 +290,10 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
|
|
289
290
|
nowText: nowText
|
290
291
|
})), /*#__PURE__*/React.createElement("h6", {
|
291
292
|
className: notificationHeaderClassName
|
292
|
-
}, notification.title), notification.description && notification.description.length && renderDescription(notification.id), notification.link && notification.link.text && notification.link.url && /*#__PURE__*/React.createElement(Link, {
|
293
|
+
}, notification.title), notification.description && notification.description.length && renderDescription(notification.id), notification.link && notification.link.text && notification.link.url && /*#__PURE__*/React.createElement(Link, _extends({
|
293
294
|
href: notification.link.url,
|
294
295
|
className: "".concat(blockClass, "__notifications-link")
|
295
|
-
}, notification.link.text)), /*#__PURE__*/React.createElement(Button, {
|
296
|
+
}, prepareProps({}, notification.link, ['text', 'url'])), notification.link.text)), /*#__PURE__*/React.createElement(Button, {
|
296
297
|
kind: "ghost",
|
297
298
|
size: "small",
|
298
299
|
renderIcon: Close16,
|
package/es/components/index.js
CHANGED
@@ -46,4 +46,11 @@ export { InlineEdit } from './InlineEdit';
|
|
46
46
|
export { EditInPlace } from './EditInPlace';
|
47
47
|
export { Guidebanner } from './Guidebanner';
|
48
48
|
export { NonLinearReading } from './NonLinearReading';
|
49
|
+
export { Coachmark } from './Coachmark';
|
50
|
+
export { CoachmarkFixed } from './CoachmarkFixed';
|
51
|
+
export { CoachmarkBeacon } from './CoachmarkBeacon';
|
52
|
+
export { CoachmarkButton } from './CoachmarkButton';
|
53
|
+
export { CoachmarkOverlayElements } from './CoachmarkOverlayElements';
|
54
|
+
export { CoachmarkOverlayElement } from './CoachmarkOverlayElement';
|
55
|
+
export { CoachmarkStack } from './CoachmarkStack';
|
49
56
|
export { InlineTip } from './InlineTip';
|