@carbon/ibm-products 1.62.1 → 1.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/index-full-carbon.css +29 -0
- 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-released-only.css +4 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +29 -0
- 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 +29 -0
- 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/Datagrid/Datagrid/DatagridContent.js +2 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +2 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +58 -33
- package/es/components/Datagrid/useFiltering.js +2 -1
- package/es/components/Datagrid/utils/handleFilterTagLabelText.js +26 -0
- package/es/components/FilterSummary/FilterSummary.js +21 -7
- package/es/components/Guidebanner/Guidebanner.js +12 -3
- package/es/components/InlineTip/InlineTip.js +17 -6
- package/es/components/TagSet/TagSet.js +22 -5
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +2 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +58 -33
- package/lib/components/Datagrid/useFiltering.js +2 -1
- package/lib/components/Datagrid/utils/handleFilterTagLabelText.js +33 -0
- package/lib/components/FilterSummary/FilterSummary.js +23 -6
- package/lib/components/Guidebanner/Guidebanner.js +12 -3
- package/lib/components/InlineTip/InlineTip.js +17 -6
- package/lib/components/TagSet/TagSet.js +21 -4
- package/package.json +3 -3
- package/scss/components/FilterSummary/_filter-summary.scss +6 -1
- package/scss/components/Guidebanner/_guidebanner.scss +25 -0
- package/scss/components/InlineTip/_inline-tip.scss +12 -0
@@ -28,16 +28,21 @@ var useFilters = function useFilters(_ref) {
|
|
28
28
|
reactTableFiltersState = _ref.reactTableFiltersState,
|
29
29
|
_ref$onCancel = _ref.onCancel,
|
30
30
|
onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel,
|
31
|
-
panelOpen = _ref.panelOpen
|
31
|
+
panelOpen = _ref.panelOpen,
|
32
|
+
isFetching = _ref.isFetching;
|
32
33
|
/** State */
|
33
34
|
var _useState = (0, _react.useState)((0, _utils.getInitialStateFromFilters)(filters, variation, reactTableFiltersState)),
|
34
35
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
35
36
|
filtersState = _useState2[0],
|
36
37
|
setFiltersState = _useState2[1];
|
37
|
-
var _useState3 = (0, _react.useState)(
|
38
|
+
var _useState3 = (0, _react.useState)(false),
|
38
39
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
39
|
-
|
40
|
-
|
40
|
+
fetchingReset = _useState4[0],
|
41
|
+
setFetchingReset = _useState4[1];
|
42
|
+
var _useState5 = (0, _react.useState)(reactTableFiltersState),
|
43
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
44
|
+
filtersObjectArray = _useState6[0],
|
45
|
+
setFiltersObjectArray = _useState6[1];
|
41
46
|
var previousState = (0, _hooks.usePreviousValue)({
|
42
47
|
panelOpen: panelOpen
|
43
48
|
});
|
@@ -53,7 +58,7 @@ var useFilters = function useFilters(_ref) {
|
|
53
58
|
/** Methods */
|
54
59
|
// If the user decides to cancel or click outside the flyout, it reverts back to the filters that were
|
55
60
|
// there when they opened the flyout
|
56
|
-
var revertToPreviousFilters = function
|
61
|
+
var revertToPreviousFilters = (0, _react.useCallback)(function () {
|
57
62
|
setFiltersState(JSON.parse(prevFiltersRef.current));
|
58
63
|
setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
|
59
64
|
setAllFilters(JSON.parse(lastAppliedFilters.current));
|
@@ -63,7 +68,7 @@ var useFilters = function useFilters(_ref) {
|
|
63
68
|
holdingPrevFiltersRef.current = JSON.parse(prevFiltersRef.current);
|
64
69
|
holdingLastAppliedFiltersRef.current = JSON.parse(prevFiltersObjectArrayRef.current);
|
65
70
|
holdingPrevFiltersObjectArrayRef.current = JSON.parse(lastAppliedFilters.current);
|
66
|
-
};
|
71
|
+
}, [setAllFilters]);
|
67
72
|
var reset = (0, _react.useCallback)(function () {
|
68
73
|
// When we reset we want the "initialFilters" to be an empty array
|
69
74
|
var resetFiltersArray = [];
|
@@ -80,6 +85,7 @@ var useFilters = function useFilters(_ref) {
|
|
80
85
|
// Update their respective refs so everything is in sync
|
81
86
|
prevFiltersRef.current = JSON.stringify(initialFiltersState);
|
82
87
|
prevFiltersObjectArrayRef.current = JSON.stringify(initialFiltersObjectArray);
|
88
|
+
lastAppliedFilters.current = JSON.stringify([]);
|
83
89
|
}, [filters, setAllFilters, variation]);
|
84
90
|
var applyFilters = function applyFilters(_ref2) {
|
85
91
|
var column = _ref2.column,
|
@@ -170,7 +176,6 @@ var useFilters = function useFilters(_ref) {
|
|
170
176
|
};
|
171
177
|
/** Render the individual filter component */
|
172
178
|
var renderFilter = function renderFilter(_ref3) {
|
173
|
-
var _filtersState$column, _filtersState$column2;
|
174
179
|
var type = _ref3.type,
|
175
180
|
column = _ref3.column,
|
176
181
|
components = _ref3.props;
|
@@ -257,31 +262,36 @@ var useFilters = function useFilters(_ref) {
|
|
257
262
|
}));
|
258
263
|
break;
|
259
264
|
case _constants.RADIO:
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
}, radio)
|
284
|
-
|
265
|
+
{
|
266
|
+
var _filtersState$column, _components$DefaultRa, _components$DefaultRa2, _filtersState$column2, _components$DefaultRa3, _components$DefaultRa4, _components$DefaultRa5, _components$DefaultRa6, _components$DefaultRa7, _components$DefaultRa8;
|
267
|
+
var _components$RadioButt = _objectSpread({}, components.RadioButtonGroup),
|
268
|
+
name = _components$RadioButt.name;
|
269
|
+
filter = /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.FormGroup, components.FormGroup, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioButtonGroup, (0, _extends2.default)({}, components.RadioButtonGroup, {
|
270
|
+
valueSelected: ((_filtersState$column = filtersState[column]) === null || _filtersState$column === void 0 ? void 0 : _filtersState$column.value) === '' ? (_components$DefaultRa = (_components$DefaultRa2 = components.DefaultRadioButton) === null || _components$DefaultRa2 === void 0 ? void 0 : _components$DefaultRa2.value) !== null && _components$DefaultRa !== void 0 ? _components$DefaultRa : 'Any' : (_filtersState$column2 = filtersState[column]) === null || _filtersState$column2 === void 0 ? void 0 : _filtersState$column2.value,
|
271
|
+
onChange: function onChange(selected) {
|
272
|
+
var _components$RadioButt2, _components$RadioButt3;
|
273
|
+
setFiltersState(_objectSpread(_objectSpread({}, filtersState), {}, (0, _defineProperty2.default)({}, column, {
|
274
|
+
value: selected,
|
275
|
+
type: type
|
276
|
+
})));
|
277
|
+
applyFilters({
|
278
|
+
column: column,
|
279
|
+
value: selected,
|
280
|
+
type: type
|
281
|
+
});
|
282
|
+
(_components$RadioButt2 = (_components$RadioButt3 = components.RadioButtonGroup).onChange) === null || _components$RadioButt2 === void 0 ? void 0 : _components$RadioButt2.call(_components$RadioButt3, selected);
|
283
|
+
}
|
284
|
+
}), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioButton, (0, _extends2.default)({
|
285
|
+
id: (_components$DefaultRa3 = components === null || components === void 0 ? void 0 : (_components$DefaultRa4 = components.DefaultRadioButton) === null || _components$DefaultRa4 === void 0 ? void 0 : _components$DefaultRa4.id) !== null && _components$DefaultRa3 !== void 0 ? _components$DefaultRa3 : "any__".concat(name),
|
286
|
+
labelText: (_components$DefaultRa5 = components === null || components === void 0 ? void 0 : (_components$DefaultRa6 = components.DefaultRadioButton) === null || _components$DefaultRa6 === void 0 ? void 0 : _components$DefaultRa6.labelText) !== null && _components$DefaultRa5 !== void 0 ? _components$DefaultRa5 : 'Any',
|
287
|
+
value: (_components$DefaultRa7 = components === null || components === void 0 ? void 0 : (_components$DefaultRa8 = components.DefaultRadioButton) === null || _components$DefaultRa8 === void 0 ? void 0 : _components$DefaultRa8.value) !== null && _components$DefaultRa7 !== void 0 ? _components$DefaultRa7 : 'Any'
|
288
|
+
}, components.DefaultRadioButton)), components.RadioButton.map(function (radio) {
|
289
|
+
var _ref4, _radio$id;
|
290
|
+
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.RadioButton, (0, _extends2.default)({
|
291
|
+
key: (_ref4 = (_radio$id = radio.id) !== null && _radio$id !== void 0 ? _radio$id : radio.labelText) !== null && _ref4 !== void 0 ? _ref4 : radio.value
|
292
|
+
}, radio));
|
293
|
+
})));
|
294
|
+
}
|
285
295
|
break;
|
286
296
|
case _constants.DROPDOWN:
|
287
297
|
filter = /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Dropdown, (0, _extends2.default)({}, components.Dropdown, {
|
@@ -317,6 +327,7 @@ var useFilters = function useFilters(_ref) {
|
|
317
327
|
*/
|
318
328
|
(0, _react.useEffect)(function () {
|
319
329
|
if (!panelOpen && previousState !== null && previousState !== void 0 && previousState.panelOpen) {
|
330
|
+
revertToPreviousFilters();
|
320
331
|
setAllFilters(holdingLastAppliedFiltersRef.current);
|
321
332
|
}
|
322
333
|
if (panelOpen && !(previousState !== null && previousState !== void 0 && previousState.panelOpen)) {
|
@@ -326,7 +337,21 @@ var useFilters = function useFilters(_ref) {
|
|
326
337
|
setAllFilters(JSON.parse(prevFiltersObjectArrayRef.current));
|
327
338
|
}
|
328
339
|
}
|
329
|
-
}, [panelOpen, previousState, previousState === null || previousState === void 0 ? void 0 : previousState.panelOpen, reset, setAllFilters]);
|
340
|
+
}, [panelOpen, previousState, previousState === null || previousState === void 0 ? void 0 : previousState.panelOpen, reset, setAllFilters, revertToPreviousFilters]);
|
341
|
+
|
342
|
+
// Re-applies filters if the Datagrid goes into a fetching state while panel is open
|
343
|
+
// and has had filters changed without applying
|
344
|
+
(0, _react.useEffect)(function () {
|
345
|
+
if (isFetching && !fetchingReset) {
|
346
|
+
setFiltersState(JSON.parse(prevFiltersRef.current));
|
347
|
+
setFiltersObjectArray(JSON.parse(prevFiltersRef.current));
|
348
|
+
setAllFilters(JSON.parse(prevFiltersObjectArrayRef.current));
|
349
|
+
setFetchingReset(true);
|
350
|
+
}
|
351
|
+
if (!isFetching) {
|
352
|
+
setFetchingReset(false);
|
353
|
+
}
|
354
|
+
}, [isFetching, reactTableFiltersState, setAllFilters, fetchingReset]);
|
330
355
|
var cancel = function cancel() {
|
331
356
|
// Reverting to previous filters only applies when using batch actions
|
332
357
|
if (updateMethod === _constants.BATCH) {
|
@@ -28,7 +28,8 @@ var useFiltering = function useFiltering(hooks) {
|
|
28
28
|
var rowValue = row.values[id];
|
29
29
|
var startDateObj = (0, _typeof2.default)(startDate) === 'object' ? startDate : new Date(startDate);
|
30
30
|
var endDateObj = (0, _typeof2.default)(endDate) === 'object' ? endDate : new Date(endDate);
|
31
|
-
|
31
|
+
var rowValueDateObj = (0, _typeof2.default)(rowValue) === 'object' ? rowValue : new Date(rowValue);
|
32
|
+
if (rowValueDateObj.getTime() <= endDateObj.getTime() && rowValueDateObj.getTime() >= startDateObj.getTime()) {
|
32
33
|
// In date range
|
33
34
|
return true;
|
34
35
|
} else {
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.handleFilterTagLabelText = void 0;
|
7
|
+
/**
|
8
|
+
* Copyright IBM Corp. 2023, 2023
|
9
|
+
*
|
10
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
12
|
+
*/
|
13
|
+
|
14
|
+
// Example usage for custom filter tag labels, in practice this
|
15
|
+
// is where a translation service would be utilized. This
|
16
|
+
// utility is for storybook demonstration purposes only.
|
17
|
+
var handleFilterTagLabelText = function handleFilterTagLabelText(key, value) {
|
18
|
+
switch (key) {
|
19
|
+
case 'role':
|
20
|
+
return "Role: ".concat(value);
|
21
|
+
case 'joined':
|
22
|
+
return "Joined: ".concat(value);
|
23
|
+
case 'visits':
|
24
|
+
return "Visits: ".concat(value);
|
25
|
+
case 'passwordStrength':
|
26
|
+
return "Password strength: ".concat(value);
|
27
|
+
case 'status':
|
28
|
+
return "Status: ".concat(value);
|
29
|
+
default:
|
30
|
+
return "".concat(key, ": ").concat(value);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
exports.handleFilterTagLabelText = handleFilterTagLabelText;
|
@@ -1,6 +1,7 @@
|
|
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
|
});
|
@@ -8,16 +9,20 @@ exports.default = void 0;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
10
11
|
var _carbonComponentsReact = require("carbon-components-react");
|
11
|
-
var _react =
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
12
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
13
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
14
15
|
var _TagSet = require("../TagSet");
|
15
16
|
var _settings = require("../../settings");
|
17
|
+
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
16
18
|
var _excluded = ["key", "value"];
|
19
|
+
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); }
|
20
|
+
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; }
|
17
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; }
|
18
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; }
|
19
23
|
var blockClass = "".concat(_settings.pkg.prefix, "--filter-summary");
|
20
24
|
var FilterSummary = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
25
|
+
var _filterSummaryClearBu;
|
21
26
|
var _ref$className = _ref.className,
|
22
27
|
className = _ref$className === void 0 ? '' : _ref$className,
|
23
28
|
_ref$clearFiltersText = _ref.clearFiltersText,
|
@@ -29,7 +34,10 @@ var FilterSummary = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
29
34
|
_ref$renderLabel = _ref.renderLabel,
|
30
35
|
renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel,
|
31
36
|
_ref$overflowType = _ref.overflowType,
|
32
|
-
overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType
|
37
|
+
overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType,
|
38
|
+
_ref$clearButtonInlin = _ref.clearButtonInline,
|
39
|
+
clearButtonInline = _ref$clearButtonInlin === void 0 ? true : _ref$clearButtonInlin;
|
40
|
+
var filterSummaryId = "".concat(blockClass, "__").concat((0, _uuidv.default)());
|
33
41
|
var tagFilters = filters.map(function (_ref2) {
|
34
42
|
var _renderLabel;
|
35
43
|
var key = _ref2.key,
|
@@ -40,26 +48,35 @@ var FilterSummary = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
|
|
40
48
|
label: (_renderLabel = renderLabel === null || renderLabel === void 0 ? void 0 : renderLabel(key, value)) !== null && _renderLabel !== void 0 ? _renderLabel : "".concat(key, ": ").concat(value)
|
41
49
|
});
|
42
50
|
});
|
51
|
+
var filterSummaryClearButton = (0, _react.useRef)();
|
52
|
+
var filterSummaryRef = (0, _react.useRef)();
|
53
|
+
var localRef = filterSummaryRef || ref;
|
43
54
|
return /*#__PURE__*/_react.default.createElement("div", {
|
44
|
-
ref:
|
45
|
-
className: (0, _classnames.default)([blockClass, className])
|
55
|
+
ref: localRef,
|
56
|
+
className: (0, _classnames.default)([blockClass, className]),
|
57
|
+
id: filterSummaryId
|
46
58
|
}, /*#__PURE__*/_react.default.createElement(_TagSet.TagSet, {
|
47
59
|
allTagsModalSearchLabel: "Search all tags",
|
48
60
|
allTagsModalSearchPlaceholderText: "Search all tags",
|
49
61
|
allTagsModalTitle: "All tags",
|
50
62
|
showAllTagsLabel: "View all tags",
|
51
63
|
tags: tagFilters,
|
52
|
-
overflowType: overflowType
|
64
|
+
overflowType: overflowType,
|
65
|
+
className: (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__clear-button-inline"), clearButtonInline)),
|
66
|
+
containingElementRef: localRef,
|
67
|
+
measurementOffset: filterSummaryClearButton === null || filterSummaryClearButton === void 0 ? void 0 : (_filterSummaryClearBu = filterSummaryClearButton.current) === null || _filterSummaryClearBu === void 0 ? void 0 : _filterSummaryClearBu.offsetWidth
|
53
68
|
}), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
54
69
|
kind: "ghost",
|
55
70
|
size: "sm",
|
56
|
-
onClick: clearFilters
|
71
|
+
onClick: clearFilters,
|
72
|
+
ref: filterSummaryClearButton
|
57
73
|
}, clearFiltersText));
|
58
74
|
});
|
59
75
|
var componentName = 'FilterSummary';
|
60
76
|
FilterSummary.displayName = componentName;
|
61
77
|
FilterSummary.propTypes = {
|
62
78
|
className: _propTypes.default.string,
|
79
|
+
clearButtonInline: _propTypes.default.boolean,
|
63
80
|
clearFilters: _propTypes.default.func.isRequired,
|
64
81
|
clearFiltersText: _propTypes.default.string,
|
65
82
|
filters: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
@@ -18,7 +18,7 @@ var _carbonComponentsReact = require("carbon-components-react");
|
|
18
18
|
var _Carousel = require("../Carousel");
|
19
19
|
var _devtools = require("../../global/js/utils/devtools");
|
20
20
|
var _settings = require("../../settings");
|
21
|
-
var _excluded = ["children", "className", "collapsible", "onClose", "closeIconDescription", "collapseButtonLabel", "expandButtonLabel", "nextIconDescription", "previousIconDescription", "title"];
|
21
|
+
var _excluded = ["children", "className", "collapsible", "onClose", "withLeftGutter", "closeIconDescription", "collapseButtonLabel", "expandButtonLabel", "nextIconDescription", "previousIconDescription", "title"];
|
22
22
|
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); }
|
23
23
|
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; }
|
24
24
|
// Carbon and package components we use.
|
@@ -29,6 +29,7 @@ var blockClass = "".concat(_settings.pkg.prefix, "--guidebanner");
|
|
29
29
|
var componentName = 'Guidebanner';
|
30
30
|
var defaults = {
|
31
31
|
collapsible: false,
|
32
|
+
withLeftGutter: false,
|
32
33
|
// Labels
|
33
34
|
closeIconDescription: 'Close',
|
34
35
|
collapseButtonLabel: 'Read less',
|
@@ -47,6 +48,8 @@ var Guidebanner = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
47
48
|
_ref$collapsible = _ref.collapsible,
|
48
49
|
collapsible = _ref$collapsible === void 0 ? defaults.collapsible : _ref$collapsible,
|
49
50
|
onClose = _ref.onClose,
|
51
|
+
_ref$withLeftGutter = _ref.withLeftGutter,
|
52
|
+
withLeftGutter = _ref$withLeftGutter === void 0 ? defaults.withLeftGutter : _ref$withLeftGutter,
|
50
53
|
_ref$closeIconDescrip = _ref.closeIconDescription,
|
51
54
|
closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
|
52
55
|
_ref$collapseButtonLa = _ref.collapseButtonLabel,
|
@@ -82,7 +85,7 @@ var Guidebanner = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
82
85
|
};
|
83
86
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
84
87
|
"aria-expanded": !isCollapsed,
|
85
|
-
className: (0, _classnames.default)(blockClass, className,
|
88
|
+
className: (0, _classnames.default)(blockClass, className, collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), withLeftGutter && "".concat(blockClass, "__with-left-gutter")),
|
86
89
|
ref: ref
|
87
90
|
}, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement(_iconsReact.Idea20, {
|
88
91
|
className: "".concat(blockClass, "__icon-idea")
|
@@ -222,5 +225,11 @@ Guidebanner.propTypes = {
|
|
222
225
|
/**
|
223
226
|
* Title text.
|
224
227
|
*/
|
225
|
-
title: _propTypes.default.string.isRequired
|
228
|
+
title: _propTypes.default.string.isRequired,
|
229
|
+
/**
|
230
|
+
* If true, insert 1 rem of "space" on the left of the component.
|
231
|
+
* This will allow the component's content to line up with other
|
232
|
+
* content on the page under special circumstances.
|
233
|
+
*/
|
234
|
+
withLeftGutter: _propTypes.default.bool
|
226
235
|
};
|
@@ -19,7 +19,7 @@ var _SteppedAnimatedMedia = require("../SteppedAnimatedMedia");
|
|
19
19
|
var _devtools = require("../../global/js/utils/devtools");
|
20
20
|
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
21
21
|
var _settings = require("../../settings");
|
22
|
-
var _excluded = ["children", "className", "closeIconDescription", "collapsible", "collapseButtonLabel", "expandButtonLabel", "narrow", "onClick", "onClose", "tertiaryButtonLabel", "
|
22
|
+
var _excluded = ["action", "children", "className", "closeIconDescription", "collapsible", "collapseButtonLabel", "expandButtonLabel", "media", "narrow", "onClick", "onClose", "tertiaryButtonLabel", "title", "withLeftGutter"];
|
23
23
|
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); }
|
24
24
|
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; }
|
25
25
|
// Carbon and package components we use.
|
@@ -47,6 +47,7 @@ var defaults = {
|
|
47
47
|
collapseButtonLabel: 'Read less',
|
48
48
|
expandButtonLabel: 'Read more',
|
49
49
|
narrow: false,
|
50
|
+
withLeftGutter: false,
|
50
51
|
onClick: function onClick() {},
|
51
52
|
onClose: function onClose() {}
|
52
53
|
};
|
@@ -55,7 +56,8 @@ var defaults = {
|
|
55
56
|
* TODO: A description of the component.
|
56
57
|
*/
|
57
58
|
var InlineTip = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
58
|
-
var
|
59
|
+
var action = _ref.action,
|
60
|
+
children = _ref.children,
|
59
61
|
className = _ref.className,
|
60
62
|
_ref$closeIconDescrip = _ref.closeIconDescription,
|
61
63
|
closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
|
@@ -65,15 +67,16 @@ var InlineTip = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
65
67
|
collapseButtonLabel = _ref$collapseButtonLa === void 0 ? defaults.collapseButtonLabel : _ref$collapseButtonLa,
|
66
68
|
_ref$expandButtonLabe = _ref.expandButtonLabel,
|
67
69
|
expandButtonLabel = _ref$expandButtonLabe === void 0 ? defaults.expandButtonLabel : _ref$expandButtonLabe,
|
70
|
+
media = _ref.media,
|
68
71
|
_ref$narrow = _ref.narrow,
|
69
72
|
narrow = _ref$narrow === void 0 ? defaults.narrow : _ref$narrow,
|
70
73
|
onClick = _ref.onClick,
|
71
74
|
onClose = _ref.onClose,
|
72
75
|
tertiaryButtonLabel = _ref.tertiaryButtonLabel,
|
73
|
-
action = _ref.action,
|
74
76
|
_ref$title = _ref.title,
|
75
77
|
title = _ref$title === void 0 ? defaults.title : _ref$title,
|
76
|
-
|
78
|
+
_ref$withLeftGutter = _ref.withLeftGutter,
|
79
|
+
withLeftGutter = _ref$withLeftGutter === void 0 ? defaults.withLeftGutter : _ref$withLeftGutter,
|
77
80
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
78
81
|
var _useState = (0, _react.useState)(collapsible),
|
79
82
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
@@ -100,7 +103,7 @@ var InlineTip = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
100
103
|
// Apply the block class to the main HTML element
|
101
104
|
className,
|
102
105
|
// Apply any supplied class names to the main HTML element.
|
103
|
-
|
106
|
+
collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), media && "".concat(blockClass, "__has-media"), [narrow ? "".concat(blockClass, "__narrow") : "".concat(blockClass, "__wide")], withLeftGutter && !narrow && "".concat(blockClass, "__with-left-gutter")),
|
104
107
|
ref: ref,
|
105
108
|
role: "complementary"
|
106
109
|
}, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
@@ -228,5 +231,13 @@ InlineTip.propTypes = {
|
|
228
231
|
/**
|
229
232
|
* The title of the InlineTip.
|
230
233
|
*/
|
231
|
-
title: _propTypes.default.string.isRequired
|
234
|
+
title: _propTypes.default.string.isRequired,
|
235
|
+
/**
|
236
|
+
* If true, insert 1 rem of "space" on the left of the component.
|
237
|
+
* This will allow the component's content to line up with other
|
238
|
+
* content on the page under special circumstances.
|
239
|
+
*
|
240
|
+
* This will only be applied when `narrow` is false.
|
241
|
+
*/
|
242
|
+
withLeftGutter: _propTypes.default.bool
|
232
243
|
};
|
@@ -21,7 +21,7 @@ var _useResizeObserver = require("../../global/js/hooks/useResizeObserver");
|
|
21
21
|
var _devtools = require("../../global/js/utils/devtools");
|
22
22
|
var _propsHelper = require("../../global/js/utils/props-helper");
|
23
23
|
var _settings = require("../../settings");
|
24
|
-
var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags"],
|
24
|
+
var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags", "containingElementRef", "measurementOffset"],
|
25
25
|
_excluded2 = ["label", "id"],
|
26
26
|
_excluded3 = ["label"];
|
27
27
|
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); }
|
@@ -36,6 +36,7 @@ var allTagsModalSearchThreshold = 10;
|
|
36
36
|
var defaults = {
|
37
37
|
align: 'start',
|
38
38
|
// allTagsModalTarget: document.body,
|
39
|
+
measurementOffset: 0,
|
39
40
|
overflowAlign: 'center',
|
40
41
|
overflowDirection: 'bottom',
|
41
42
|
overflowType: 'default'
|
@@ -59,6 +60,9 @@ var TagSet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
59
60
|
allTagsModalSearchPlaceholderText = _ref.allTagsModalSearchPlaceholderText,
|
60
61
|
showAllTagsLabel = _ref.showAllTagsLabel,
|
61
62
|
tags = _ref.tags,
|
63
|
+
containingElementRef = _ref.containingElementRef,
|
64
|
+
_ref$measurementOffse = _ref.measurementOffset,
|
65
|
+
measurementOffset = _ref$measurementOffse === void 0 ? defaults.measurementOffset : _ref$measurementOffse,
|
62
66
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
63
67
|
var _useState = (0, _react.useState)(3),
|
64
68
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
@@ -163,7 +167,9 @@ var TagSet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
163
167
|
// how many will fit?
|
164
168
|
var willFit = 0;
|
165
169
|
if (sizingTags.length > 0) {
|
166
|
-
var
|
170
|
+
var optionalContainingElement = containingElementRef === null || containingElementRef === void 0 ? void 0 : containingElementRef.current;
|
171
|
+
var measurementOffsetValue = typeof measurementOffset === 'number' ? measurementOffset : 0;
|
172
|
+
var spaceAvailable = optionalContainingElement ? optionalContainingElement.offsetWidth - measurementOffsetValue : tagSetRef.current.offsetWidth;
|
167
173
|
for (var i in sizingTags) {
|
168
174
|
var tagWidth = sizingTags[i].offsetWidth;
|
169
175
|
if (spaceAvailable >= tagWidth) {
|
@@ -186,7 +192,7 @@ var TagSet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
186
192
|
} else {
|
187
193
|
setDisplayCount(maxVisible ? Math.min(willFit, maxVisible) : willFit);
|
188
194
|
}
|
189
|
-
}, [maxVisible, multiline, sizingTags, tagSetRef]);
|
195
|
+
}, [maxVisible, multiline, sizingTags, tagSetRef, containingElementRef, measurementOffset]);
|
190
196
|
(0, _react.useEffect)(function () {
|
191
197
|
checkFullyVisibleTags();
|
192
198
|
}, [checkFullyVisibleTags, maxVisible, multiline, sizingTags]);
|
@@ -208,7 +214,8 @@ var TagSet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
208
214
|
setShowAllModalOpen(false);
|
209
215
|
};
|
210
216
|
(0, _useResizeObserver.useResizeObserver)(sizingContainerRef, handleSizerTagsResize);
|
211
|
-
|
217
|
+
var resizeOption = containingElementRef ? containingElementRef : tagSetRef;
|
218
|
+
(0, _useResizeObserver.useResizeObserver)(resizeOption, handleResize);
|
212
219
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
213
220
|
className: (0, _classnames.default)([blockClass, className]),
|
214
221
|
ref: tagSetRef
|
@@ -289,10 +296,20 @@ TagSet.propTypes = {
|
|
289
296
|
* className
|
290
297
|
*/
|
291
298
|
className: _propTypes.default.string,
|
299
|
+
/**
|
300
|
+
* Optional ref for custom resize container to measure available space
|
301
|
+
* Default will measure the available space of the TagSet container itself.
|
302
|
+
*/
|
303
|
+
containingElementRef: _propTypes.default.object,
|
292
304
|
/**
|
293
305
|
* maximum visible tags
|
294
306
|
*/
|
295
307
|
maxVisible: _propTypes.default.number,
|
308
|
+
/**
|
309
|
+
* Specify offset amount for measure available space, only used when `containingElementSelector`
|
310
|
+
* is also provided
|
311
|
+
*/
|
312
|
+
measurementOffset: _propTypes.default.number,
|
296
313
|
/**
|
297
314
|
* display tags in multiple lines
|
298
315
|
*/
|
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.64.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -92,10 +92,10 @@
|
|
92
92
|
"@carbon/themes": "^10.55.3",
|
93
93
|
"@carbon/type": "^10.45.3",
|
94
94
|
"carbon-components": "^10.58.12",
|
95
|
-
"carbon-components-react": "^7.59.
|
95
|
+
"carbon-components-react": "^7.59.17",
|
96
96
|
"carbon-icons": "^7.0.7",
|
97
97
|
"react": "^16.8.6 || ^17.0.1",
|
98
98
|
"react-dom": "^16.8.6 || ^17.0.1"
|
99
99
|
},
|
100
|
-
"gitHead": "
|
100
|
+
"gitHead": "8d199ba7fdf1afcd494af8771abd2483c197d319"
|
101
101
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
//
|
2
|
-
// Copyright IBM Corp. 2022
|
2
|
+
// Copyright IBM Corp. 2022, 2023
|
3
3
|
//
|
4
4
|
// This source code is licensed under the Apache-2.0 license found in the
|
5
5
|
// LICENSE file in the root directory of this source tree.
|
@@ -17,3 +17,8 @@ $block-class: #{$pkg-prefix}--filter-summary;
|
|
17
17
|
border-top: 1px solid $ui-03;
|
18
18
|
background: $ui-01;
|
19
19
|
}
|
20
|
+
|
21
|
+
.#{$block-class}
|
22
|
+
.#{$pkg-prefix}--tag-set.#{$pkg-prefix}--tag-set.#{$block-class}__clear-button-inline {
|
23
|
+
width: auto;
|
24
|
+
}
|
@@ -249,6 +249,31 @@
|
|
249
249
|
z-index: 6001 !important;
|
250
250
|
}
|
251
251
|
}
|
252
|
+
|
253
|
+
// Exception handling.
|
254
|
+
// If "withLeftgutter", then:
|
255
|
+
// - insert 1 rem of more "space" on the left.
|
256
|
+
// - move icon 1 rem more to the right.
|
257
|
+
&__with-left-gutter {
|
258
|
+
.#{$block-class}__icon-idea {
|
259
|
+
left: $spacing-07;
|
260
|
+
}
|
261
|
+
.#{$block-class}__title {
|
262
|
+
padding-left: calc($horizontal-margin + $spacing-05);
|
263
|
+
}
|
264
|
+
.#{$block-class}__navigation {
|
265
|
+
padding-left: $spacing-05;
|
266
|
+
}
|
267
|
+
// Override Carousel settings
|
268
|
+
// - insert 1 rem of more "space" on the left.
|
269
|
+
.#{$pkg-prefix}--carousel__elements-container {
|
270
|
+
padding-left: $spacing-05;
|
271
|
+
}
|
272
|
+
// - expand "fade" to cover more of the left side of the carousel.
|
273
|
+
.#{$pkg-prefix}--carousel__elements-container--scrolled {
|
274
|
+
width: $spacing-10;
|
275
|
+
}
|
276
|
+
}
|
252
277
|
}
|
253
278
|
}
|
254
279
|
|
@@ -70,6 +70,18 @@
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
}
|
73
|
+
|
74
|
+
// Exception handling.
|
75
|
+
// If "withLeftgutter", then:
|
76
|
+
// - insert 1 rem of more "space" on the left.
|
77
|
+
// - move icon 1 rem more to the right.
|
78
|
+
&.#{$block-class}__with-left-gutter {
|
79
|
+
padding-left: $spacing-10;
|
80
|
+
|
81
|
+
.#{$block-class}__icon-idea {
|
82
|
+
left: $spacing-07;
|
83
|
+
}
|
84
|
+
}
|
73
85
|
}
|
74
86
|
|
75
87
|
// layout only: narrow
|