@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
@@ -1,19 +1,26 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
7
8
|
exports.default = void 0;
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10
|
-
var
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
11
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
12
14
|
var _carbonComponentsReact = require("carbon-components-react");
|
15
|
+
var _layout = require("@carbon/layout");
|
13
16
|
var _commonColumnIds = require("../common-column-ids");
|
14
17
|
var _settings = require("../../../settings");
|
18
|
+
var _stateReducer = require("./addons/stateReducer");
|
19
|
+
var _getColTitle = _interopRequireDefault(require("../utils/getColTitle"));
|
20
|
+
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); }
|
21
|
+
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; }
|
15
22
|
/**
|
16
|
-
* Copyright IBM Corp. 2020,
|
23
|
+
* Copyright IBM Corp. 2020, 2023
|
17
24
|
*
|
18
25
|
* This source code is licensed under the Apache-2.0 license found in the
|
19
26
|
* LICENSE file in the root directory of this source tree.
|
@@ -22,16 +29,86 @@ var _settings = require("../../../settings");
|
|
22
29
|
// @flow
|
23
30
|
|
24
31
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
32
|
+
var getAccessibilityProps = function getAccessibilityProps(header) {
|
33
|
+
var props = {};
|
34
|
+
var title = (0, _getColTitle.default)(header);
|
35
|
+
if (title) {
|
36
|
+
props.title = title;
|
37
|
+
} else {
|
38
|
+
props['aria-hidden'] = true;
|
39
|
+
}
|
40
|
+
return props;
|
41
|
+
};
|
25
42
|
var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
43
|
+
// Used to measure the height of the table and uses that value
|
44
|
+
// to display a vertical line to indicate the column you are resizing
|
45
|
+
(0, _react.useEffect)(function () {
|
46
|
+
var tableId = datagridState.tableId;
|
47
|
+
if (tableId) {
|
48
|
+
var gridElement = document.querySelector("#".concat(tableId));
|
49
|
+
var tableElement = gridElement.querySelector('table');
|
50
|
+
var headerRowElement = document.querySelector("#".concat(tableId, " .").concat(blockClass, "__head"));
|
51
|
+
var hasHorizontalScrollbar = tableElement.scrollWidth > tableElement.clientWidth;
|
52
|
+
var scrollBuffer = hasHorizontalScrollbar ? 18 : 2;
|
53
|
+
var tableToolbar = gridElement.querySelector(".".concat(blockClass, "__table-toolbar"));
|
54
|
+
var tableToolbarHeight = (tableToolbar === null || tableToolbar === void 0 ? void 0 : tableToolbar.offsetHeight) || 0;
|
55
|
+
var setCustomValues = function setCustomValues(_ref) {
|
56
|
+
var _ref$rowHeight = _ref.rowHeight,
|
57
|
+
rowHeight = _ref$rowHeight === void 0 ? 48 : _ref$rowHeight,
|
58
|
+
gridHeight = _ref.gridHeight;
|
59
|
+
headerRowElement.style.setProperty("--".concat(blockClass, "--row-height"), (0, _layout.px)(rowHeight));
|
60
|
+
headerRowElement.style.setProperty("--".concat(blockClass, "--grid-height"), (0, _layout.px)(gridHeight - scrollBuffer - tableToolbarHeight));
|
61
|
+
};
|
62
|
+
setCustomValues({
|
63
|
+
gridHeight: gridElement.offsetHeight,
|
64
|
+
rowHeight: headerRowElement.clientHeight
|
65
|
+
});
|
66
|
+
}
|
67
|
+
}, [datagridState.rowSize, datagridState.tableId, datagridState]);
|
68
|
+
var _useState = (0, _react.useState)(2),
|
69
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
70
|
+
incrementAmount = _useState2[0];
|
71
|
+
var getClientXPosition = function getClientXPosition(event) {
|
72
|
+
var isTouchEvent = false;
|
73
|
+
if (event.type === 'touchstart') {
|
74
|
+
// Do not respond to multiple touches (e.g. 2 or 3 fingers)
|
75
|
+
if (event.touches && event.touches.length > 1) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
isTouchEvent = true;
|
79
|
+
}
|
80
|
+
var clientX = isTouchEvent ? Math.round(event.touches[0].clientX) : event.clientX;
|
81
|
+
var closestHeader = event.target.closest('th');
|
82
|
+
var closestHeaderCoords = closestHeader.getBoundingClientRect();
|
83
|
+
var headerOffset = closestHeaderCoords.left;
|
84
|
+
var offsetValue = clientX - headerOffset;
|
85
|
+
return offsetValue;
|
86
|
+
};
|
87
|
+
(0, _react.useEffect)(function () {
|
88
|
+
var isResizing = datagridState.state.isResizing;
|
89
|
+
if (isResizing) {
|
90
|
+
var onColResizeEnd = datagridState.onColResizeEnd;
|
91
|
+
document.addEventListener('mouseup', function () {
|
92
|
+
(0, _stateReducer.handleColumnResizeEndEvent)(datagridState.dispatch, onColResizeEnd, isResizing);
|
93
|
+
document.activeElement.blur();
|
94
|
+
});
|
95
|
+
}
|
96
|
+
return function () {
|
97
|
+
document.removeEventListener('mouseup', function () {
|
98
|
+
return (0, _stateReducer.handleColumnResizeEndEvent)(datagridState.dispatch);
|
99
|
+
});
|
100
|
+
};
|
101
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
102
|
+
}, [datagridState.state.isResizing]);
|
26
103
|
return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({}, headerGroup.getHeaderGroupProps({
|
27
104
|
role: false
|
28
105
|
}), {
|
29
106
|
className: (0, _classnames.default)("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
|
30
107
|
ref: headRef
|
31
|
-
}), datagridState.headers.filter(function (
|
32
|
-
var isVisible =
|
108
|
+
}), datagridState.headers.filter(function (_ref2) {
|
109
|
+
var isVisible = _ref2.isVisible;
|
33
110
|
return isVisible;
|
34
|
-
}).map(function (header) {
|
111
|
+
}).map(function (header, index) {
|
35
112
|
var _cx;
|
36
113
|
if (header.id === _commonColumnIds.selectionColumnId) {
|
37
114
|
// render directly without the wrapper TableHeader
|
@@ -39,13 +116,59 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
39
116
|
key: header.id
|
40
117
|
});
|
41
118
|
}
|
119
|
+
var _ref3 = header || 50,
|
120
|
+
minWidth = _ref3.minWidth;
|
121
|
+
var visibleColumns = datagridState.visibleColumns,
|
122
|
+
state = datagridState.state,
|
123
|
+
dispatch = datagridState.dispatch,
|
124
|
+
onColResizeEnd = datagridState.onColResizeEnd;
|
125
|
+
var columnResizing = state.columnResizing,
|
126
|
+
isResizing = state.isResizing;
|
127
|
+
var columnWidths = columnResizing.columnWidths;
|
128
|
+
var originalCol = visibleColumns[index];
|
42
129
|
return /*#__PURE__*/_react.default.createElement(TableHeader, (0, _extends2.default)({}, header.getHeaderProps({
|
43
130
|
role: false
|
44
131
|
}), {
|
45
132
|
className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
|
46
133
|
key: header.id
|
47
|
-
}), header.render('Header'), header.getResizerProps && /*#__PURE__*/_react.default.createElement("
|
48
|
-
|
134
|
+
}, getAccessibilityProps(header)), header.render('Header'), header.getResizerProps && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, header.getResizerProps(), {
|
135
|
+
onMouseMove: function onMouseMove(event) {
|
136
|
+
if (isResizing) {
|
137
|
+
var newWidth = getClientXPosition(event);
|
138
|
+
// Sets a min width for resizing so at least one character from the column header is visible
|
139
|
+
if (newWidth >= 50) {
|
140
|
+
(0, _stateReducer.handleColumnResizingEvent)(dispatch, header, newWidth);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
},
|
144
|
+
onMouseDown: function onMouseDown() {
|
145
|
+
return (0, _stateReducer.handleColumnResizeStartEvent)(dispatch, header.id);
|
146
|
+
},
|
147
|
+
onKeyDown: function onKeyDown(event) {
|
148
|
+
var key = event.key;
|
149
|
+
if (key === 'ArrowLeft' || key === 'ArrowRight') {
|
150
|
+
var currentColumnWidth = columnWidths[header.id] || (datagridState.isTableSortable && originalCol.width < 90 ? 90 : originalCol.width);
|
151
|
+
if (key === 'ArrowLeft') {
|
152
|
+
if (currentColumnWidth - incrementAmount > Math.max(minWidth, 50)) {
|
153
|
+
var newWidth = currentColumnWidth - incrementAmount;
|
154
|
+
(0, _stateReducer.handleColumnResizingEvent)(dispatch, header, newWidth, true);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
if (key === 'ArrowRight') {
|
158
|
+
var _newWidth = currentColumnWidth + incrementAmount;
|
159
|
+
(0, _stateReducer.handleColumnResizingEvent)(dispatch, header, _newWidth, true);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
},
|
163
|
+
onKeyUp: function onKeyUp() {
|
164
|
+
return (0, _stateReducer.handleColumnResizeEndEvent)(dispatch, onColResizeEnd, header.id);
|
165
|
+
},
|
166
|
+
className: (0, _classnames.default)("".concat(blockClass, "__col-resizer-range")),
|
167
|
+
type: "range",
|
168
|
+
defaultValue: originalCol.width,
|
169
|
+
"aria-label": "Resize column"
|
170
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
171
|
+
className: "".concat(blockClass, "__col-resize-indicator")
|
49
172
|
})));
|
50
173
|
}));
|
51
174
|
};
|
@@ -11,6 +11,7 @@ var _carbonComponentsReact = require("carbon-components-react");
|
|
11
11
|
var _common = require("./common");
|
12
12
|
var _DraggableElement = _interopRequireDefault(require("../../DraggableElement"));
|
13
13
|
var _settings = require("../../../../../settings");
|
14
|
+
var _getColTitle2 = _interopRequireDefault(require("../../../utils/getColTitle"));
|
14
15
|
/**
|
15
16
|
* Copyright IBM Corp. 2023, 2023
|
16
17
|
*
|
@@ -29,40 +30,17 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
|
|
29
30
|
setAriaRegionText = _ref.setAriaRegionText,
|
30
31
|
setColumnsObject = _ref.setColumnsObject,
|
31
32
|
setFocusIndex = _ref.setFocusIndex;
|
32
|
-
// This function recursively looks for the nested header element until we can find the key which contains the title.
|
33
|
-
// This can happen if multiple hooks are used together that manipulate the rendering of the column
|
34
|
-
// header, such as `useColumnCenterAlign` and `useSortableColumns`.
|
35
|
-
var getNestedTitle = function getNestedTitle(component) {
|
36
|
-
if (component && !component.key) {
|
37
|
-
return getNestedTitle(component.children);
|
38
|
-
}
|
39
|
-
if (component && component.key && typeof component.key === 'string') {
|
40
|
-
return component.key;
|
41
|
-
}
|
42
|
-
};
|
43
|
-
var getColTitle = function getColTitle(col) {
|
44
|
-
if (!col) {
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
var checkTitle = function checkTitle() {
|
48
|
-
if (col.Header().props.children.props && col.Header().props.children.props.title) {
|
49
|
-
return col.Header().props.children.props.title;
|
50
|
-
}
|
51
|
-
return getNestedTitle(col.Header().props.children.props);
|
52
|
-
};
|
53
|
-
return typeof (col === null || col === void 0 ? void 0 : col.Header) === 'function' ? checkTitle() : col.Header.props.title;
|
54
|
-
};
|
55
33
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, columns
|
56
34
|
// hide the columns without Header, e.g the sticky actions, spacer
|
57
35
|
.filter(function (colDef) {
|
58
|
-
return !!
|
36
|
+
return !!(0, _getColTitle2.default)(colDef);
|
59
37
|
}).filter(Boolean).filter(function (colDef) {
|
60
38
|
return !colDef.isAction;
|
61
39
|
}).filter(function (colDef) {
|
62
40
|
var _getColTitle;
|
63
|
-
return filterString.length === 0 || ((_getColTitle =
|
41
|
+
return filterString.length === 0 || ((_getColTitle = (0, _getColTitle2.default)(colDef)) === null || _getColTitle === void 0 ? void 0 : _getColTitle.toLowerCase().includes(filterString)) && colDef.id !== 'spacer';
|
64
42
|
}).map(function (colDef, i) {
|
65
|
-
var colHeaderTitle =
|
43
|
+
var colHeaderTitle = (0, _getColTitle2.default)(colDef);
|
66
44
|
var searchString = new RegExp('(' + filterString + ')');
|
67
45
|
var res = filterString.length ? colHeaderTitle.toLowerCase().split(searchString) : null;
|
68
46
|
var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
|
@@ -0,0 +1,122 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.stateReducer = exports.handleColumnResizingEvent = exports.handleColumnResizeStartEvent = exports.handleColumnResizeEndEvent = void 0;
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10
|
+
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; }
|
11
|
+
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) { (0, _defineProperty2.default)(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; }
|
12
|
+
/**
|
13
|
+
* Copyright IBM Corp. 2023, 2023
|
14
|
+
*
|
15
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
17
|
+
*/
|
18
|
+
|
19
|
+
var COLUMN_RESIZE_START = 'columnStartResizing';
|
20
|
+
var COLUMN_RESIZING = 'columnResizing';
|
21
|
+
var COLUMN_RESIZE_END = 'columnDoneResizing';
|
22
|
+
var INIT = 'init';
|
23
|
+
var handleColumnResizeStartEvent = function handleColumnResizeStartEvent(dispatch, headerId) {
|
24
|
+
dispatch({
|
25
|
+
type: COLUMN_RESIZE_START,
|
26
|
+
payload: {
|
27
|
+
headerId: headerId
|
28
|
+
}
|
29
|
+
});
|
30
|
+
};
|
31
|
+
exports.handleColumnResizeStartEvent = handleColumnResizeStartEvent;
|
32
|
+
var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId) {
|
33
|
+
dispatch({
|
34
|
+
type: COLUMN_RESIZE_END,
|
35
|
+
payload: {
|
36
|
+
onColResizeEnd: onColResizeEnd,
|
37
|
+
headerId: headerId
|
38
|
+
}
|
39
|
+
});
|
40
|
+
};
|
41
|
+
exports.handleColumnResizeEndEvent = handleColumnResizeEndEvent;
|
42
|
+
var handleColumnResizingEvent = function handleColumnResizingEvent(dispatch, header, newWidth, isKeyEvent) {
|
43
|
+
if (isKeyEvent) {
|
44
|
+
dispatch({
|
45
|
+
type: COLUMN_RESIZE_START,
|
46
|
+
payload: {
|
47
|
+
newWidth: newWidth,
|
48
|
+
headerId: header.id,
|
49
|
+
defaultWidth: header.originalWidth
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}
|
53
|
+
dispatch({
|
54
|
+
type: COLUMN_RESIZING,
|
55
|
+
payload: {
|
56
|
+
newWidth: newWidth,
|
57
|
+
headerId: header.id,
|
58
|
+
defaultWidth: header.originalWidth
|
59
|
+
}
|
60
|
+
});
|
61
|
+
};
|
62
|
+
exports.handleColumnResizingEvent = handleColumnResizingEvent;
|
63
|
+
var stateReducer = function stateReducer(newState, action) {
|
64
|
+
switch (action.type) {
|
65
|
+
case INIT:
|
66
|
+
{
|
67
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
68
|
+
isResizing: false
|
69
|
+
});
|
70
|
+
}
|
71
|
+
case COLUMN_RESIZE_START:
|
72
|
+
{
|
73
|
+
var headerId = action.payload.headerId;
|
74
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
75
|
+
isResizing: headerId
|
76
|
+
});
|
77
|
+
}
|
78
|
+
case COLUMN_RESIZING:
|
79
|
+
{
|
80
|
+
var _ref = action.payload || {},
|
81
|
+
_headerId = _ref.headerId,
|
82
|
+
newWidth = _ref.newWidth,
|
83
|
+
defaultWidth = _ref.defaultWidth;
|
84
|
+
var newColumnWidth = {};
|
85
|
+
if (typeof _headerId === 'undefined') {
|
86
|
+
return _objectSpread({}, newState);
|
87
|
+
}
|
88
|
+
newColumnWidth[_headerId] = newWidth;
|
89
|
+
var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref2) {
|
90
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
91
|
+
_ = _ref3[0],
|
92
|
+
value = _ref3[1];
|
93
|
+
return !isNaN(value);
|
94
|
+
}));
|
95
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
96
|
+
isResizing: _headerId,
|
97
|
+
columnResizing: _objectSpread(_objectSpread({}, newState.columnResizing), {}, {
|
98
|
+
columnWidth: defaultWidth,
|
99
|
+
columnWidths: _objectSpread(_objectSpread({}, cleanedWidths), newColumnWidth),
|
100
|
+
headerIdWidths: [_headerId, newWidth]
|
101
|
+
})
|
102
|
+
});
|
103
|
+
}
|
104
|
+
case COLUMN_RESIZE_END:
|
105
|
+
{
|
106
|
+
var _action$payload = action.payload,
|
107
|
+
onColResizeEnd = _action$payload.onColResizeEnd,
|
108
|
+
_headerId2 = _action$payload.headerId;
|
109
|
+
var currentColumn = {};
|
110
|
+
currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
|
111
|
+
var allChangedColumns = newState.columnResizing.columnWidths;
|
112
|
+
var isResizing = newState.isResizing;
|
113
|
+
if (isResizing) {
|
114
|
+
onColResizeEnd === null || onColResizeEnd === void 0 ? void 0 : onColResizeEnd(currentColumn, allChangedColumns);
|
115
|
+
}
|
116
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
117
|
+
isResizing: false
|
118
|
+
});
|
119
|
+
}
|
120
|
+
}
|
121
|
+
};
|
122
|
+
exports.stateReducer = stateReducer;
|
@@ -17,6 +17,7 @@ var _useRowSize = _interopRequireDefault(require("./useRowSize"));
|
|
17
17
|
var _DatagridHeaderRow = _interopRequireDefault(require("./Datagrid/DatagridHeaderRow"));
|
18
18
|
var _useFlexResize = _interopRequireDefault(require("./useFlexResize"));
|
19
19
|
var _useFloatingScroll = _interopRequireDefault(require("./useFloatingScroll"));
|
20
|
+
var _stateReducer = require("./Datagrid/addons/stateReducer");
|
20
21
|
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; }
|
21
22
|
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) { (0, _defineProperty2.default)(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; }
|
22
23
|
var useDatagrid = function useDatagrid(params) {
|
@@ -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 = _reactTable.useTable.apply(void 0, [_objectSpread({
|
33
|
+
var tableState = _reactTable.useTable.apply(void 0, [_objectSpread(_objectSpread({
|
33
34
|
tableId: tableId
|
34
|
-
}, params)
|
35
|
+
}, params), {}, {
|
36
|
+
stateReducer: _stateReducer.stateReducer
|
37
|
+
})].concat(defaultPlugins, plugins, defaultEndPlugins, (0, _toConsumableArray2.default)(clientEndPlugins)));
|
35
38
|
return tableState;
|
36
39
|
};
|
37
40
|
var _default = useDatagrid;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
// This function recursively looks for the nested header element until we can find the key which contains the title.
|
8
|
+
// This can happen if multiple hooks are used together that manipulate the rendering of the column
|
9
|
+
// header, such as `useColumnCenterAlign` and `useSortableColumns`.
|
10
|
+
var getNestedTitle = function getNestedTitle(component) {
|
11
|
+
if (component && !component.key) {
|
12
|
+
return getNestedTitle(component.children);
|
13
|
+
}
|
14
|
+
if (component && component.key && typeof component.key === 'string') {
|
15
|
+
return component.key;
|
16
|
+
}
|
17
|
+
};
|
18
|
+
var getColTitle = function getColTitle(col) {
|
19
|
+
var _col$Header, _col$Header$props;
|
20
|
+
if (!col) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
var checkTitle = function checkTitle() {
|
24
|
+
if (col.Header().props.children.props && col.Header().props.children.props.title) {
|
25
|
+
return col.Header().props.children.props.title;
|
26
|
+
}
|
27
|
+
return getNestedTitle(col.Header().props.children.props);
|
28
|
+
};
|
29
|
+
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;
|
30
|
+
};
|
31
|
+
var _default = getColTitle;
|
32
|
+
exports.default = _default;
|
@@ -17,6 +17,7 @@ var _devtools = require("../../global/js/utils/devtools");
|
|
17
17
|
var _hooks = require("../../global/js/hooks");
|
18
18
|
var _settings = require("../../settings");
|
19
19
|
var _utils = require("./utils");
|
20
|
+
var _propsHelper = require("../../global/js/utils/props-helper");
|
20
21
|
var _NotificationsEmptyState = require("../EmptyStates/NotificationsEmptyState");
|
21
22
|
var _carbonComponentsReact = require("carbon-components-react");
|
22
23
|
var _iconsReact = require("@carbon/icons-react");
|
@@ -285,10 +286,10 @@ var NotificationsPanel = /*#__PURE__*/_react.default.forwardRef(function (_ref,
|
|
285
286
|
nowText: nowText
|
286
287
|
})), /*#__PURE__*/_react.default.createElement("h6", {
|
287
288
|
className: notificationHeaderClassName
|
288
|
-
}, notification.title), notification.description && notification.description.length && renderDescription(notification.id), notification.link && notification.link.text && notification.link.url && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Link, {
|
289
|
+
}, notification.title), notification.description && notification.description.length && renderDescription(notification.id), notification.link && notification.link.text && notification.link.url && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Link, (0, _extends2.default)({
|
289
290
|
href: notification.link.url,
|
290
291
|
className: "".concat(blockClass, "__notifications-link")
|
291
|
-
}, notification.link.text)), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
292
|
+
}, (0, _propsHelper.prepareProps)({}, notification.link, ['text', 'url'])), notification.link.text)), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
292
293
|
kind: "ghost",
|
293
294
|
size: "small",
|
294
295
|
renderIcon: _iconsReact.Close16,
|
package/lib/components/index.js
CHANGED
@@ -21,6 +21,48 @@ Object.defineProperty(exports, "Cascade", {
|
|
21
21
|
return _Cascade.Cascade;
|
22
22
|
}
|
23
23
|
});
|
24
|
+
Object.defineProperty(exports, "Coachmark", {
|
25
|
+
enumerable: true,
|
26
|
+
get: function get() {
|
27
|
+
return _Coachmark.Coachmark;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
Object.defineProperty(exports, "CoachmarkBeacon", {
|
31
|
+
enumerable: true,
|
32
|
+
get: function get() {
|
33
|
+
return _CoachmarkBeacon.CoachmarkBeacon;
|
34
|
+
}
|
35
|
+
});
|
36
|
+
Object.defineProperty(exports, "CoachmarkButton", {
|
37
|
+
enumerable: true,
|
38
|
+
get: function get() {
|
39
|
+
return _CoachmarkButton.CoachmarkButton;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
Object.defineProperty(exports, "CoachmarkFixed", {
|
43
|
+
enumerable: true,
|
44
|
+
get: function get() {
|
45
|
+
return _CoachmarkFixed.CoachmarkFixed;
|
46
|
+
}
|
47
|
+
});
|
48
|
+
Object.defineProperty(exports, "CoachmarkOverlayElement", {
|
49
|
+
enumerable: true,
|
50
|
+
get: function get() {
|
51
|
+
return _CoachmarkOverlayElement.CoachmarkOverlayElement;
|
52
|
+
}
|
53
|
+
});
|
54
|
+
Object.defineProperty(exports, "CoachmarkOverlayElements", {
|
55
|
+
enumerable: true,
|
56
|
+
get: function get() {
|
57
|
+
return _CoachmarkOverlayElements.CoachmarkOverlayElements;
|
58
|
+
}
|
59
|
+
});
|
60
|
+
Object.defineProperty(exports, "CoachmarkStack", {
|
61
|
+
enumerable: true,
|
62
|
+
get: function get() {
|
63
|
+
return _CoachmarkStack.CoachmarkStack;
|
64
|
+
}
|
65
|
+
});
|
24
66
|
Object.defineProperty(exports, "ComboButton", {
|
25
67
|
enumerable: true,
|
26
68
|
get: function get() {
|
@@ -530,4 +572,11 @@ var _InlineEdit = require("./InlineEdit");
|
|
530
572
|
var _EditInPlace = require("./EditInPlace");
|
531
573
|
var _Guidebanner = require("./Guidebanner");
|
532
574
|
var _NonLinearReading = require("./NonLinearReading");
|
575
|
+
var _Coachmark = require("./Coachmark");
|
576
|
+
var _CoachmarkFixed = require("./CoachmarkFixed");
|
577
|
+
var _CoachmarkBeacon = require("./CoachmarkBeacon");
|
578
|
+
var _CoachmarkButton = require("./CoachmarkButton");
|
579
|
+
var _CoachmarkOverlayElements = require("./CoachmarkOverlayElements");
|
580
|
+
var _CoachmarkOverlayElement = require("./CoachmarkOverlayElement");
|
581
|
+
var _CoachmarkStack = require("./CoachmarkStack");
|
533
582
|
var _InlineTip = require("./InlineTip");
|
@@ -15,22 +15,38 @@ var _react = require("react");
|
|
15
15
|
*/
|
16
16
|
|
17
17
|
var useResizeObserver = function useResizeObserver(ref, callback) {
|
18
|
-
var _useState = (0, _react.useState)(
|
18
|
+
var _useState = (0, _react.useState)(-1),
|
19
19
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
20
20
|
width = _useState2[0],
|
21
21
|
setWidth = _useState2[1];
|
22
|
-
var _useState3 = (0, _react.useState)(
|
22
|
+
var _useState3 = (0, _react.useState)(-1),
|
23
23
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
24
24
|
height = _useState4[0],
|
25
25
|
setHeight = _useState4[1];
|
26
26
|
var entriesToHandle = (0, _react.useRef)(null);
|
27
27
|
var cb = (0, _react.useRef)(callback);
|
28
28
|
(0, _react.useEffect)(function () {
|
29
|
-
// ref for callback removes it as dependency
|
29
|
+
// ref for callback removes it as dependency from useLayoutEffect
|
30
30
|
// This significantly reduces repeated calls if a function is redefined on every
|
31
31
|
// render
|
32
32
|
cb.current = callback;
|
33
33
|
}, [callback]);
|
34
|
+
(0, _react.useEffect)(function () {
|
35
|
+
var getInitialSize = function getInitialSize() {
|
36
|
+
if (ref.current) {
|
37
|
+
var _ref$current, _ref$current2;
|
38
|
+
var refComputedStyle = window.getComputedStyle(ref.current);
|
39
|
+
var initialWidth = (((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.offsetWidth) || 0) - (parseFloat((refComputedStyle === null || refComputedStyle === void 0 ? void 0 : refComputedStyle.paddingLeft) || 0), parseFloat((refComputedStyle === null || refComputedStyle === void 0 ? void 0 : refComputedStyle.paddingRight) || 0));
|
40
|
+
var initialHeight = (((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.offsetHeight) || 0) - (parseFloat((refComputedStyle === null || refComputedStyle === void 0 ? void 0 : refComputedStyle.paddingTop) || 0), parseFloat((refComputedStyle === null || refComputedStyle === void 0 ? void 0 : refComputedStyle.paddingLeft) || 0));
|
41
|
+
setWidth(initialWidth);
|
42
|
+
setHeight(initialHeight);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
if (!(ref !== null && ref !== void 0 && ref.current) || width >= 0 && height >= 0) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
getInitialSize();
|
49
|
+
}, [width, height, ref]);
|
34
50
|
(0, _react.useLayoutEffect)(function () {
|
35
51
|
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
36
52
|
return;
|
@@ -74,7 +74,14 @@ var defaults = {
|
|
74
74
|
// Novice to pro components not yet reviewed and released:
|
75
75
|
InlineTip: false,
|
76
76
|
Guidebanner: false,
|
77
|
-
NonLinearReading: false
|
77
|
+
NonLinearReading: false,
|
78
|
+
Coachmark: false,
|
79
|
+
CoachmarkBeacon: false,
|
80
|
+
CoachmarkButton: false,
|
81
|
+
CoachmarkFixed: false,
|
82
|
+
CoachmarkOverlayElement: false,
|
83
|
+
CoachmarkOverlayElements: false,
|
84
|
+
CoachmarkStack: false
|
78
85
|
/* new component flags here - comment used by generate CLI */
|
79
86
|
},
|
80
87
|
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.57.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,5 +96,5 @@
|
|
96
96
|
"react": "^16.8.6 || ^17.0.1",
|
97
97
|
"react-dom": "^16.8.6 || ^17.0.1"
|
98
98
|
},
|
99
|
-
"gitHead": "
|
99
|
+
"gitHead": "1d221bb1501e276983498e37ed58599c841fa202"
|
100
100
|
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
//
|
2
|
+
// Copyright IBM Corp. 2023, 2023
|
3
|
+
//
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
6
|
+
//
|
7
|
+
|
8
|
+
@import './styles/coachmark-dragbar';
|
9
|
+
@import './styles/coachmark-header';
|
10
|
+
@import './styles/coachmark-overlay';
|
11
|
+
@import './styles/coachmark-tagline';
|
@@ -0,0 +1,20 @@
|
|
1
|
+
//
|
2
|
+
// Copyright IBM Corp. 2023, 2023
|
3
|
+
//
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
6
|
+
//
|
7
|
+
|
8
|
+
@import '../../global/styles/project-settings';
|
9
|
+
|
10
|
+
.CoachmarkBaseExampleUsage {
|
11
|
+
position: relative;
|
12
|
+
display: inline-block;
|
13
|
+
max-height: 100%;
|
14
|
+
box-sizing: border-box;
|
15
|
+
|
16
|
+
/* stylelint-disable-next-line carbon/layout-token-use */
|
17
|
+
padding: 1rem;
|
18
|
+
margin-left: 50%;
|
19
|
+
transform: translateX(-50%);
|
20
|
+
}
|