@carbon/ibm-products 2.20.0 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -5
- package/css/index-full-carbon.css +548 -253
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +208 -177
- 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 +252 -189
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +233 -193
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/ActionSet/ActionSet.js +3 -4
- package/es/components/AddSelect/AddSelectBody.js +2 -2
- package/es/components/AddSelect/AddSelectRow.js +2 -2
- package/es/components/Card/Card.js +1 -2
- package/es/components/Card/CardHeader.js +1 -2
- package/es/components/CreateFullPage/CreateFullPageStep.js +1 -2
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +1 -2
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +1 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +1 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.js +10 -10
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -11
- package/es/components/Datagrid/Datagrid/DatagridRow.js +15 -11
- package/es/components/Datagrid/Datagrid/DraggableElement.js +1 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +21 -11
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +22 -12
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +31 -74
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +2 -3
- package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +1 -5
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +2 -3
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +2 -2
- package/es/components/Datagrid/useActionsColumn.js +1 -2
- package/es/components/Datagrid/useDefaultStringRenderer.js +1 -2
- package/es/components/Datagrid/useFiltering.js +1 -0
- package/es/components/Datagrid/useNestedRowExpander.js +1 -2
- package/es/components/Datagrid/useNestedRows.js +49 -33
- package/es/components/Datagrid/useOnRowClick.js +1 -1
- package/es/components/Datagrid/useRowIsMouseOver.js +3 -1
- package/es/components/Datagrid/useSelectRows.js +1 -2
- package/es/components/Datagrid/useSortableColumns.js +1 -2
- package/es/components/Datagrid/useStickyColumn.js +3 -4
- package/es/components/Datagrid/utils/filterPropsForTesting.js +149 -0
- package/es/components/DelimitedList/DelimitedList.docs-page.js +15 -0
- package/es/components/DelimitedList/DelimitedList.js +73 -0
- package/es/components/DelimitedList/index.js +8 -0
- package/es/components/EditInPlace/EditInPlace.js +1 -2
- package/es/components/EditTearsheet/EditTearsheetForm.js +1 -2
- package/es/components/FilterSummary/FilterSummary.js +15 -12
- package/es/components/NotificationsPanel/NotificationsPanel.js +2 -3
- package/es/components/PageHeader/PageHeader.js +9 -11
- package/es/components/Saving/Saving.js +6 -6
- package/es/components/SidePanel/SidePanel.js +147 -191
- package/es/components/TagSet/TagSet.js +21 -5
- package/es/components/TagSet/TagSetOverflow.js +14 -10
- package/es/components/Tearsheet/Tearsheet.js +5 -0
- package/es/components/Tearsheet/TearsheetNarrow.js +5 -0
- package/es/components/Tearsheet/TearsheetShell.js +9 -9
- package/es/components/WebTerminal/WebTerminal.js +1 -2
- package/es/components/index.js +2 -1
- package/es/global/js/hooks/useResizeObserver.js +5 -2
- package/es/global/js/package-settings.js +1 -0
- package/lib/components/ActionSet/ActionSet.js +3 -4
- package/lib/components/AddSelect/AddSelectBody.js +2 -2
- package/lib/components/AddSelect/AddSelectRow.js +2 -2
- package/lib/components/Card/Card.js +1 -2
- package/lib/components/Card/CardHeader.js +1 -2
- package/lib/components/CreateFullPage/CreateFullPageStep.js +1 -2
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +1 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +1 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +1 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +10 -10
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -11
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +15 -11
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +1 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +21 -11
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +22 -12
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +31 -74
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +2 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +1 -5
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +2 -3
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +2 -2
- package/lib/components/Datagrid/useActionsColumn.js +1 -2
- package/lib/components/Datagrid/useDefaultStringRenderer.js +1 -2
- package/lib/components/Datagrid/useFiltering.js +1 -0
- package/lib/components/Datagrid/useNestedRowExpander.js +1 -2
- package/lib/components/Datagrid/useNestedRows.js +49 -33
- package/lib/components/Datagrid/useOnRowClick.js +1 -1
- package/lib/components/Datagrid/useRowIsMouseOver.js +3 -1
- package/lib/components/Datagrid/useSelectRows.js +1 -2
- package/lib/components/Datagrid/useSortableColumns.js +1 -2
- package/lib/components/Datagrid/useStickyColumn.js +3 -4
- package/lib/components/Datagrid/utils/filterPropsForTesting.js +156 -0
- package/lib/components/DelimitedList/DelimitedList.docs-page.js +25 -0
- package/lib/components/DelimitedList/DelimitedList.js +78 -0
- package/lib/components/DelimitedList/index.js +12 -0
- package/lib/components/EditInPlace/EditInPlace.js +1 -2
- package/lib/components/EditTearsheet/EditTearsheetForm.js +1 -2
- package/lib/components/FilterSummary/FilterSummary.js +15 -12
- package/lib/components/NotificationsPanel/NotificationsPanel.js +2 -3
- package/lib/components/PageHeader/PageHeader.js +9 -11
- package/lib/components/Saving/Saving.js +6 -6
- package/lib/components/SidePanel/SidePanel.js +147 -191
- package/lib/components/TagSet/TagSet.js +21 -5
- package/lib/components/TagSet/TagSetOverflow.js +13 -9
- package/lib/components/Tearsheet/Tearsheet.js +5 -0
- package/lib/components/Tearsheet/TearsheetNarrow.js +5 -0
- package/lib/components/Tearsheet/TearsheetShell.js +9 -9
- package/lib/components/WebTerminal/WebTerminal.js +1 -2
- package/lib/components/index.js +8 -1
- package/lib/global/js/hooks/useResizeObserver.js +5 -2
- package/lib/global/js/package-settings.js +1 -0
- package/package.json +9 -8
- package/scss/components/Datagrid/_datagrid.scss +4 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +9 -1
- package/scss/components/Datagrid/styles/_useStickyColumn.scss +2 -0
- package/scss/components/DelimitedList/_carbon-imports.scss +9 -0
- package/scss/components/DelimitedList/_delimited-list.scss +27 -0
- package/scss/components/DelimitedList/_index-with-carbon.scss +9 -0
- package/scss/components/DelimitedList/_index.scss +8 -0
- package/scss/components/Saving/_saving.scss +6 -0
- package/scss/components/SidePanel/_side-panel-variables.scss +5 -1
- package/scss/components/SidePanel/_side-panel.scss +158 -186
- package/scss/components/TagSet/_tag-set.scss +4 -1
- package/scss/components/_index-with-carbon.scss +1 -0
- package/scss/components/_index.scss +1 -0
- package/telemetry.yml +790 -0
@@ -61,7 +61,7 @@ var defaults = {
|
|
61
61
|
* Side panels keep users in-context of a page while performing tasks like navigating, editing, viewing details, or configuring something new.
|
62
62
|
*/
|
63
63
|
var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
64
|
-
var _window
|
64
|
+
var _window;
|
65
65
|
var actionToolbarButtons = _ref.actionToolbarButtons,
|
66
66
|
actions = _ref.actions,
|
67
67
|
_ref$animateTitle = _ref.animateTitle,
|
@@ -99,47 +99,56 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
99
99
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
100
100
|
animationComplete = _useState2[0],
|
101
101
|
setAnimationComplete = _useState2[1];
|
102
|
-
var
|
103
|
-
|
104
|
-
|
105
|
-
setPanelHeight = _useState4[1];
|
106
|
-
var sidePanelRef = (0, _react.useRef)();
|
107
|
-
var sidePanelOverlayRef = (0, _react.useRef)();
|
102
|
+
var localRef = (0, _react.useRef)();
|
103
|
+
var sidePanelRef = ref || localRef;
|
104
|
+
var overlayRef = (0, _react.useRef)();
|
108
105
|
var startTrapRef = (0, _react.useRef)();
|
109
106
|
var endTrapRef = (0, _react.useRef)();
|
110
|
-
var
|
111
|
-
var
|
107
|
+
var innerContentRef = (0, _react.useRef)();
|
108
|
+
var closeRef = (0, _react.useRef)();
|
109
|
+
var animatedScrollRef = (0, _react.useRef)();
|
110
|
+
var headerRef = (0, _react.useRef)();
|
111
|
+
var titleRef = (0, _react.useRef)();
|
112
|
+
var collapsedTitleRef = (0, _react.useRef)();
|
113
|
+
var labelTextRef = (0, _react.useRef)();
|
114
|
+
var subtitleRef = (0, _react.useRef)();
|
112
115
|
var previousState = (0, _hooks.usePreviousValue)({
|
113
116
|
size: size,
|
114
117
|
open: open
|
115
118
|
});
|
119
|
+
var _useState3 = (0, _react.useState)(-1),
|
120
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
121
|
+
scrollAnimationDistance = _useState4[0],
|
122
|
+
setScrollAnimationDistance = _useState4[1];
|
123
|
+
var _useState5 = (0, _react.useState)(true),
|
124
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
125
|
+
doAnimateTitle = _useState6[0],
|
126
|
+
setDoAnimateTitle = _useState6[1];
|
127
|
+
(0, _react.useEffect)(function () {
|
128
|
+
setDoAnimateTitle(animateTitle);
|
129
|
+
}, [animateTitle]);
|
130
|
+
var handleScroll = (0, _react.useCallback)(function () {
|
131
|
+
var scrollTop = animatedScrollRef.current.scrollTop;
|
132
|
+
sidePanelRef.current.style.setProperty("--".concat(blockClass, "--scroll-animation-progress"), Math.min(scrollTop, scrollAnimationDistance) / scrollAnimationDistance);
|
133
|
+
}, [scrollAnimationDistance, sidePanelRef]);
|
116
134
|
var reducedMotion = typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
117
135
|
matches: true
|
118
136
|
};
|
119
|
-
var getActionsContainerElement = (0, _react.useCallback)(function () {
|
120
|
-
var sidePanelOuter = document.querySelector("#".concat(id));
|
121
|
-
return sidePanelOuter && sidePanelOuter.querySelector(".".concat(blockClass, "__actions-container"));
|
122
|
-
}, [id]);
|
123
137
|
|
124
138
|
// scroll panel to top going between steps
|
125
139
|
(0, _react.useEffect)(function () {
|
126
|
-
|
127
|
-
|
128
|
-
var
|
129
|
-
var scrollableSection = panelRef.current.querySelector(".".concat(blockClass, "__inner-content"));
|
130
|
-
var sidePanelOuter = document.querySelector("#".concat(id));
|
131
|
-
var initialTitleHeight = (_document$querySelect = document.querySelector(".".concat(blockClass, "__title-container"))) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.offsetHeight;
|
140
|
+
if (sidePanelRef && sidePanelRef.current) {
|
141
|
+
var _animatedScrollRef$cu;
|
142
|
+
var scrollableSection = (_animatedScrollRef$cu = animatedScrollRef.current) !== null && _animatedScrollRef$cu !== void 0 ? _animatedScrollRef$cu : innerContentRef.current;
|
132
143
|
scrollableSection.scrollTop = 0;
|
133
144
|
// The size of the panel has changed while it is still opened
|
134
|
-
// so we need to scroll it to the top and reset the
|
145
|
+
// so we need to scroll it to the top and reset the header
|
135
146
|
// height css custom property
|
136
147
|
if ((previousState === null || previousState === void 0 ? void 0 : previousState.size) !== size) {
|
137
|
-
var _sidePanelOuter$style;
|
138
148
|
scrollableSection.scrollTop = 0;
|
139
|
-
sidePanelOuter === null || sidePanelOuter === void 0 || (_sidePanelOuter$style = sidePanelOuter.style) === null || _sidePanelOuter$style === void 0 || _sidePanelOuter$style.setProperty("--".concat(blockClass, "--title-container-height"), "".concat(Number(initialTitleHeight), "px"));
|
140
149
|
}
|
141
150
|
}
|
142
|
-
}, [currentStep,
|
151
|
+
}, [currentStep, sidePanelRef, size, previousState === null || previousState === void 0 ? void 0 : previousState.size, id]);
|
143
152
|
|
144
153
|
// set initial focus when side panel opens
|
145
154
|
(0, _react.useEffect)(function () {
|
@@ -149,7 +158,7 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
149
158
|
if (primaryFocusElement) {
|
150
159
|
return primaryFocusElement;
|
151
160
|
} else {
|
152
|
-
return
|
161
|
+
return closeRef && closeRef.current;
|
153
162
|
}
|
154
163
|
};
|
155
164
|
var focusButton = function focusButton(focusContainerElement) {
|
@@ -157,19 +166,9 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
157
166
|
target === null || target === void 0 || target.focus();
|
158
167
|
};
|
159
168
|
if (open && animationComplete) {
|
160
|
-
focusButton(
|
169
|
+
focusButton(innerContentRef.current);
|
161
170
|
}
|
162
171
|
}, [selectorPrimaryFocus, open, animationComplete]);
|
163
|
-
(0, _react.useEffect)(function () {
|
164
|
-
if (open && actions && actions.length && animationComplete) {
|
165
|
-
var _sidePanelOuter$style2;
|
166
|
-
var sidePanelOuter = document.querySelector("#".concat(id));
|
167
|
-
var actionsContainer = getActionsContainerElement();
|
168
|
-
var actionsHeight = (actionsContainer === null || actionsContainer === void 0 ? void 0 : actionsContainer.offsetHeight) + 16; // add additional 1rem spacing to bottom padding
|
169
|
-
actionsHeight = "".concat(Math.round(actionsHeight / 16), "rem");
|
170
|
-
sidePanelOuter === null || sidePanelOuter === void 0 || (_sidePanelOuter$style2 = sidePanelOuter.style) === null || _sidePanelOuter$style2 === void 0 || _sidePanelOuter$style2.setProperty("--".concat(blockClass, "--content-bottom-padding"), actionsHeight);
|
171
|
-
}
|
172
|
-
}, [actions, condensedActions, open, animationComplete, id, getActionsContainerElement]);
|
173
172
|
|
174
173
|
// Add console warning if labelText is provided without a title.
|
175
174
|
// This combination is not allowed.
|
@@ -178,120 +177,67 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
178
177
|
console.warn("".concat(componentName, ": The prop `labelText` was provided without a `title`. It is required to have a `title` when using the `labelText` prop."));
|
179
178
|
}
|
180
179
|
}, [labelText, title]);
|
180
|
+
var checkSetDoAnimateTitle = function checkSetDoAnimateTitle() {
|
181
|
+
if (sidePanelRef !== null && sidePanelRef !== void 0 && sidePanelRef.current && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !reducedMotion.matches) {
|
182
|
+
var _labelTextRef$current, _labelTextRef$current2, _subtitleRef$current$, _subtitleRef$current;
|
183
|
+
var titleEl = titleRef.current;
|
184
|
+
var labelHeight = (_labelTextRef$current = labelTextRef === null || labelTextRef === void 0 || (_labelTextRef$current2 = labelTextRef.current) === null || _labelTextRef$current2 === void 0 ? void 0 : _labelTextRef$current2.offsetHeight) !== null && _labelTextRef$current !== void 0 ? _labelTextRef$current : 0;
|
185
|
+
var subtitleHeight = (_subtitleRef$current$ = subtitleRef === null || subtitleRef === void 0 || (_subtitleRef$current = subtitleRef.current) === null || _subtitleRef$current === void 0 ? void 0 : _subtitleRef$current.offsetHeight) !== null && _subtitleRef$current$ !== void 0 ? _subtitleRef$current$ : 0;
|
181
186
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
var sidePanelOuter = document.querySelector("#".concat(id));
|
188
|
-
var actionsContainer = getActionsContainerElement();
|
189
|
-
var actionsHeight = (actionsContainer === null || actionsContainer === void 0 ? void 0 : actionsContainer.offsetHeight) + 16; // add additional 1rem spacing to bottom padding
|
190
|
-
actionsHeight = "".concat(Math.round(actionsHeight / 16), "rem");
|
191
|
-
sidePanelOuter === null || sidePanelOuter === void 0 || (_sidePanelOuter$style3 = sidePanelOuter.style) === null || _sidePanelOuter$style3 === void 0 || _sidePanelOuter$style3.setProperty("--".concat(blockClass, "--content-bottom-padding"), actionsHeight);
|
192
|
-
};
|
187
|
+
// Adjusts space at bottom of titles by changing where scrolling finishes
|
188
|
+
// Styles use border to save use of get computed style
|
189
|
+
var titleVerticalBorder = actionToolbarButtons ? titleEl.offsetHeight - titleEl.clientHeight : 0;
|
190
|
+
var _scrollAnimationDistance = labelHeight + subtitleHeight + titleVerticalBorder;
|
191
|
+
setScrollAnimationDistance(_scrollAnimationDistance);
|
193
192
|
|
194
|
-
|
193
|
+
// used to calculate the header moves
|
194
|
+
sidePanelRef.current.style.setProperty("--".concat(blockClass, "--scroll-animation-distance"), _scrollAnimationDistance);
|
195
|
+
var scrollEl = animatedScrollRef.current;
|
196
|
+
if (!scrollEl && animateTitle && !doAnimateTitle) {
|
197
|
+
// may be switching back based on resize
|
198
|
+
scrollEl = innerContentRef.current;
|
199
|
+
}
|
200
|
+
if (scrollEl) {
|
201
|
+
var _window2;
|
202
|
+
var innerComputed = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.getComputedStyle(innerContentRef.current);
|
203
|
+
var innerPaddingHeight = innerComputed ? parseFloat(innerComputed === null || innerComputed === void 0 ? void 0 : innerComputed.paddingTop, 10) + parseFloat(innerComputed === null || innerComputed === void 0 ? void 0 : innerComputed.paddingBottom, 10) : 0;
|
204
|
+
var canDoAnimateTitle = (!!labelText || !!actionToolbarButtons || !!subtitle) && scrollEl.scrollHeight - scrollEl.clientHeight >= _scrollAnimationDistance + innerPaddingHeight;
|
205
|
+
if (doAnimateTitle !== canDoAnimateTitle) {
|
206
|
+
// will need updating on resize
|
207
|
+
setDoAnimateTitle(canDoAnimateTitle);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
};
|
195
212
|
(0, _react.useEffect)(function () {
|
196
|
-
if (
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
var panelOuterHeight = panelHeight;
|
206
|
-
var scrollSectionHeight = (_document$querySelect2 = document.querySelector(".".concat(blockClass, "__body-content"))) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.offsetHeight;
|
207
|
-
var titleContainerHeight = (_document$querySelect3 = document.querySelector(".".concat(blockClass, "__title-container"))) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.offsetHeight;
|
208
|
-
var labelTextHeight = (_document$querySelect4 = document.querySelector(".".concat(blockClass, "__label-text"))) === null || _document$querySelect4 === void 0 ? void 0 : _document$querySelect4.offsetHeight;
|
209
|
-
var totalScrollingContentHeight = titleContainerHeight + sidePanelSubtitleElementHeight + scrollSectionHeight;
|
210
|
-
// if the difference between the total scrolling height and the panel height is less than
|
211
|
-
// the subtitleElement height OR if the subtitle element height is 0, use that difference
|
212
|
-
// as the length of the scroll animation (otherwise the animation will not be able to complete
|
213
|
-
// because there is not enough scrolling distance to complete it).
|
214
|
-
sidePanelSubtitleElementHeight = totalScrollingContentHeight - panelOuterHeight < sidePanelSubtitleElementHeight ? totalScrollingContentHeight - panelOuterHeight : sidePanelSubtitleElementHeight === 0 ? 16 : sidePanelSubtitleElementHeight;
|
215
|
-
sidePanelSubtitleElementHeight = sidePanelSubtitleElementHeight < 0 ? (sidePanelScrollArea === null || sidePanelScrollArea === void 0 ? void 0 : sidePanelScrollArea.scrollHeight) - (sidePanelScrollArea === null || sidePanelScrollArea === void 0 ? void 0 : sidePanelScrollArea.clientHeight) : sidePanelSubtitleElementHeight;
|
216
|
-
/* istanbul ignore next */
|
217
|
-
sidePanelScrollArea && sidePanelScrollArea.addEventListener('scroll', function () {
|
218
|
-
var scrollTop = sidePanelScrollArea.scrollTop;
|
219
|
-
// if scrolling has occurred
|
220
|
-
if (scrollTop > 0) {
|
221
|
-
sidePanelOuter.classList.add("".concat(blockClass, "__with-condensed-header"));
|
222
|
-
// Set subtitle opacity calculation here
|
223
|
-
// as scroll progresses
|
224
|
-
var titleOpacity = Math.min(1, (sidePanelSubtitleElementHeight - scrollTop) / sidePanelSubtitleElementHeight);
|
225
|
-
titleOpacity = titleOpacity < 0 ? 0 : titleOpacity;
|
226
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-opacity"), titleOpacity);
|
227
|
-
|
228
|
-
// Calculate divider opacity to avoid border
|
229
|
-
// abruptly appearing when scrolling starts.
|
230
|
-
// This approach uses a pseudo element and sets
|
231
|
-
// the opacity as scroll progresses.
|
232
|
-
var dividerOpacity = Math.min(scrollTop / sidePanelSubtitleElementHeight, 1);
|
233
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--divider-opacity"), "".concat(Math.min(1, dividerOpacity)));
|
234
|
-
|
235
|
-
// We need to know the height of the title element
|
236
|
-
// so that we know how far to place the action toolbar
|
237
|
-
// from the top since it is sticky
|
238
|
-
var titleTextHeight = Math.max(sidePanelTitleElement.offsetHeight);
|
239
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-height"), "".concat(titleTextHeight + 16, "px"));
|
240
|
-
|
241
|
-
// Set title y positioning
|
242
|
-
var titleYPosition = Math.min(scrollTop / sidePanelSubtitleElementHeight, 1);
|
243
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-y-position"), "".concat(-Math.abs(titleYPosition), "rem"));
|
244
|
-
|
245
|
-
// mark title with aria-hidden={true} if opacity reaches 0
|
246
|
-
if (titleOpacity === 0) {
|
247
|
-
sidePanelTitleElement.setAttribute('aria-hidden', 'true');
|
248
|
-
sidePanelCollapsedTitleElement.setAttribute('aria-hidden', 'false');
|
249
|
-
}
|
213
|
+
if (doAnimateTitle && animatedScrollRef.current) {
|
214
|
+
// only add scroll if the doAnimateTitle is already true
|
215
|
+
// should come back through if false and canDoAnimateTitle is true
|
216
|
+
animatedScrollRef.current.addEventListener('scroll', handleScroll);
|
217
|
+
}
|
218
|
+
if (!doAnimateTitle && sidePanelRef.current) {
|
219
|
+
sidePanelRef.current.style.setProperty("--".concat(blockClass, "--scroll-animation-progress"), 0);
|
220
|
+
}
|
221
|
+
}, [animatedScrollRef, doAnimateTitle, handleScroll, sidePanelRef]);
|
250
222
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
223
|
+
/* istanbul ignore next */
|
224
|
+
var handleResize = function handleResize() {
|
225
|
+
checkSetDoAnimateTitle();
|
226
|
+
};
|
255
227
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-container-height"), "".concat(titleContainerHeight, "px"));
|
261
|
-
} else {
|
262
|
-
sidePanelTitleElement.setAttribute('aria-hidden', 'false');
|
263
|
-
sidePanelCollapsedTitleElement.setAttribute('aria-hidden', 'true');
|
264
|
-
sidePanelOuter.classList.remove("".concat(blockClass, "__with-condensed-header"));
|
265
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-opacity"), 1);
|
266
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-y-position"), 0);
|
267
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--divider-opacity"), 0);
|
268
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--collapsed-title-y-position"), "1rem");
|
269
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--label-text-height"), "0px");
|
270
|
-
}
|
271
|
-
});
|
272
|
-
}
|
273
|
-
if (open && !animateTitle) {
|
274
|
-
var _sidePanelOuter = document.querySelector("#".concat(id));
|
275
|
-
var _sidePanelTitleElement = document.querySelector(".".concat(blockClass, "__title-container .").concat(blockClass, "__title-text"));
|
276
|
-
var _sidePanelSubtitleElement = document.querySelector(".".concat(blockClass, "__subtitle-text"));
|
277
|
-
var actionToolbarElement = document.querySelector(".".concat(blockClass, "__action-toolbar"));
|
278
|
-
var _labelText = document.querySelector(".".concat(blockClass, "__label-text"));
|
279
|
-
var _sidePanelSubtitleElementHeight = (_sidePanelSubtitleElement === null || _sidePanelSubtitleElement === void 0 ? void 0 : _sidePanelSubtitleElement.offsetHeight) || 0;
|
280
|
-
var sidePanelActionBarElementHeight = (actionToolbarElement === null || actionToolbarElement === void 0 ? void 0 : actionToolbarElement.offsetHeight) || 0;
|
281
|
-
var titleHeight = (_sidePanelTitleElement === null || _sidePanelTitleElement === void 0 ? void 0 : _sidePanelTitleElement.offsetHeight) + 24;
|
282
|
-
var labelHeight = (_labelText === null || _labelText === void 0 ? void 0 : _labelText.offsetHeight) || 0;
|
283
|
-
_sidePanelOuter === null || _sidePanelOuter === void 0 || _sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-text-height"), "".concat(titleHeight, "px"));
|
284
|
-
_sidePanelOuter === null || _sidePanelOuter === void 0 || _sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-container-height"), "".concat(_sidePanelSubtitleElementHeight, "px"));
|
285
|
-
_sidePanelOuter === null || _sidePanelOuter === void 0 || _sidePanelOuter.style.setProperty("--".concat(blockClass, "--action-bar-container-height"), "".concat(sidePanelActionBarElementHeight, "px"));
|
286
|
-
_sidePanelOuter === null || _sidePanelOuter === void 0 || _sidePanelOuter.style.setProperty("--".concat(blockClass, "--label-text-height"), "".concat(labelHeight, "px"));
|
228
|
+
// Calculate scroll distances
|
229
|
+
(0, _react.useEffect)(function () {
|
230
|
+
if (sidePanelRef !== null && sidePanelRef !== void 0 && sidePanelRef.current && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !reducedMotion.matches) {
|
231
|
+
checkSetDoAnimateTitle();
|
287
232
|
}
|
288
|
-
|
233
|
+
|
234
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
235
|
+
}, [open, doAnimateTitle /* use do instead of animateTitle directly */, animationComplete, handleScroll, title, size, reducedMotion.matches, id, animatedScrollRef.current]);
|
289
236
|
|
290
237
|
// click outside functionality if `includeOverlay` prop is set
|
291
238
|
(0, _react.useEffect)(function () {
|
292
239
|
var handleOutsideClick = function handleOutsideClick(event) {
|
293
|
-
|
294
|
-
if (panelRef.current && sidePanelOverlayRef.current && sidePanelOverlayRef.current.contains(event.target) && onRequestClose) {
|
240
|
+
if (sidePanelRef.current && overlayRef.current && overlayRef.current.contains(event.target) && onRequestClose) {
|
295
241
|
onRequestClose();
|
296
242
|
}
|
297
243
|
};
|
@@ -309,7 +255,7 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
309
255
|
bodyElement.style.overflow = '';
|
310
256
|
document.removeEventListener('click', handleOutsideClick);
|
311
257
|
};
|
312
|
-
}, [includeOverlay, onRequestClose, open, preventCloseOnClickOutside,
|
258
|
+
}, [includeOverlay, onRequestClose, open, preventCloseOnClickOutside, onUnmount, sidePanelRef]);
|
313
259
|
|
314
260
|
// initializes the side panel to close
|
315
261
|
var onAnimationEnd = function onAnimationEnd() {
|
@@ -372,13 +318,13 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
372
318
|
|
373
319
|
// adds focus trap functionality
|
374
320
|
/* istanbul ignore next */
|
375
|
-
var handleBlur = function handleBlur(
|
376
|
-
var oldActiveNode =
|
377
|
-
currentActiveNode =
|
321
|
+
var handleBlur = function handleBlur(_ref2) {
|
322
|
+
var oldActiveNode = _ref2.target,
|
323
|
+
currentActiveNode = _ref2.relatedTarget;
|
378
324
|
// focus trap should only be set if the side panel is a `slideOver` type
|
379
|
-
if (open &&
|
325
|
+
if (open && innerContentRef && !slideIn) {
|
380
326
|
(0, _wrapFocus.default)({
|
381
|
-
bodyNode:
|
327
|
+
bodyNode: innerContentRef.current,
|
382
328
|
startTrapRef: startTrapRef,
|
383
329
|
endTrapRef: endTrapRef,
|
384
330
|
currentActiveNode: currentActiveNode,
|
@@ -386,10 +332,25 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
386
332
|
});
|
387
333
|
}
|
388
334
|
};
|
389
|
-
var primaryActionContainerClassNames = (0, _classnames.default)(["".concat(blockClass, "__actions-container"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__actions-container
|
390
|
-
var mainPanelClassNames = (0, _classnames.default)([blockClass, className, "".concat(blockClass, "__container"), "".concat(blockClass, "__container--").concat(size), (
|
335
|
+
var primaryActionContainerClassNames = (0, _classnames.default)(["".concat(blockClass, "__actions-container"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__actions-container--condensed"), condensedActions)]);
|
336
|
+
var mainPanelClassNames = (0, _classnames.default)([blockClass, className, "".concat(blockClass, "__container"), "".concat(blockClass, "__container--").concat(size), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__container-right-placement"), placement === 'right'), "".concat(blockClass, "__container-left-placement"), placement === 'left'), "".concat(blockClass, "__container--slide-in"), slideIn), "".concat(blockClass, "__container--has-slug"), slug), "".concat(blockClass, "__container--condensed-actions"), condensedActions)]);
|
337
|
+
var renderTitle = function renderTitle() {
|
338
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
339
|
+
className: (0, _classnames.default)("".concat(blockClass, "__title"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__title--no-label"), !labelTextRef.current)),
|
340
|
+
ref: titleRef
|
341
|
+
}, /*#__PURE__*/_react.default.createElement("h2", {
|
342
|
+
className: "".concat(blockClass, "__title-text"),
|
343
|
+
title: title,
|
344
|
+
"aria-hidden": false
|
345
|
+
}, title), doAnimateTitle && !reducedMotion.matches && /*#__PURE__*/_react.default.createElement("h2", {
|
346
|
+
className: "".concat(blockClass, "__collapsed-title-text"),
|
347
|
+
title: title,
|
348
|
+
"aria-hidden": true,
|
349
|
+
ref: collapsedTitleRef
|
350
|
+
}, title));
|
351
|
+
};
|
391
352
|
var renderHeader = function renderHeader() {
|
392
|
-
var _slug$type
|
353
|
+
var _slug$type;
|
393
354
|
var slugCloseSize = actions && actions.length && /l/.test(size) ? 'md' : 'sm';
|
394
355
|
var normalizedSlug;
|
395
356
|
if (slug && (slug === null || slug === void 0 || (_slug$type = slug.type) === null || _slug$type === void 0 ? void 0 : _slug$type.displayName) === 'Slug') {
|
@@ -398,8 +359,9 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
398
359
|
size: slugCloseSize
|
399
360
|
});
|
400
361
|
}
|
401
|
-
return /*#__PURE__*/_react.default.createElement(
|
402
|
-
className: (0, _classnames.default)("".concat(blockClass, "
|
362
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
363
|
+
className: (0, _classnames.default)("".concat(blockClass, "__header"), (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "--on-detail-step"), currentStep > 0), "".concat(blockClass, "__header--no-title-animation"), !doAnimateTitle), "".concat(blockClass, "__header--reduced-motion"), reducedMotion.matches)),
|
364
|
+
ref: headerRef
|
403
365
|
}, currentStep > 0 && /*#__PURE__*/_react.default.createElement(_react2.Button, {
|
404
366
|
"aria-label": navigationBackIconDescription,
|
405
367
|
kind: "ghost",
|
@@ -414,8 +376,9 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
414
376
|
className: "".concat(blockClass, "__navigation-back-button"),
|
415
377
|
onClick: onNavigationBack
|
416
378
|
}), title && title.length && labelText && labelText.length && /*#__PURE__*/_react.default.createElement("p", {
|
417
|
-
className: "".concat(blockClass, "__label-text")
|
418
|
-
|
379
|
+
className: "".concat(blockClass, "__label-text"),
|
380
|
+
ref: labelTextRef
|
381
|
+
}, labelText), title && title.length && renderTitle(), /*#__PURE__*/_react.default.createElement("div", {
|
419
382
|
className: "".concat(blockClass, "__slug-and-close")
|
420
383
|
}, normalizedSlug, /*#__PURE__*/_react.default.createElement(_react2.Button, {
|
421
384
|
"aria-label": closeIconDescription,
|
@@ -429,22 +392,23 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
429
392
|
iconDescription: closeIconDescription,
|
430
393
|
className: "".concat(blockClass, "__close-button"),
|
431
394
|
onClick: onRequestClose,
|
432
|
-
ref:
|
395
|
+
ref: closeRef
|
433
396
|
})), subtitle && /*#__PURE__*/_react.default.createElement("p", {
|
434
|
-
className: (0, _classnames.default)("".concat(blockClass, "__subtitle-text"), (
|
397
|
+
className: (0, _classnames.default)("".concat(blockClass, "__subtitle-text"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__subtitle-text-no-animation-no-action-toolbar"), !doAnimateTitle && (!actionToolbarButtons || !actionToolbarButtons.length))),
|
398
|
+
ref: subtitleRef
|
435
399
|
}, subtitle), actionToolbarButtons && actionToolbarButtons.length && /*#__PURE__*/_react.default.createElement("div", {
|
436
|
-
className:
|
437
|
-
}, actionToolbarButtons.map(function (
|
438
|
-
var label =
|
439
|
-
kind =
|
440
|
-
icon =
|
441
|
-
tooltipPosition =
|
442
|
-
tooltipAlignment =
|
443
|
-
leading =
|
444
|
-
disabled =
|
445
|
-
className =
|
446
|
-
onClick =
|
447
|
-
rest = (0, _objectWithoutProperties2.default)(
|
400
|
+
className: "".concat(blockClass, "__action-toolbar")
|
401
|
+
}, actionToolbarButtons.map(function (_ref5) {
|
402
|
+
var label = _ref5.label,
|
403
|
+
kind = _ref5.kind,
|
404
|
+
icon = _ref5.icon,
|
405
|
+
tooltipPosition = _ref5.tooltipPosition,
|
406
|
+
tooltipAlignment = _ref5.tooltipAlignment,
|
407
|
+
leading = _ref5.leading,
|
408
|
+
disabled = _ref5.disabled,
|
409
|
+
className = _ref5.className,
|
410
|
+
onClick = _ref5.onClick,
|
411
|
+
rest = (0, _objectWithoutProperties2.default)(_ref5, _excluded2);
|
448
412
|
return /*#__PURE__*/_react.default.createElement(_react2.Button, (0, _extends2.default)({}, rest, {
|
449
413
|
key: label,
|
450
414
|
kind: kind || 'ghost',
|
@@ -460,24 +424,18 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
460
424
|
}), leading && label);
|
461
425
|
})));
|
462
426
|
};
|
463
|
-
var
|
464
|
-
return /*#__PURE__*/_react.default.createElement(
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
}, title), animateTitle && title && title.length && !reducedMotion.matches && /*#__PURE__*/_react.default.createElement("h2", {
|
469
|
-
className: "".concat(blockClass, "__collapsed-title-text"),
|
470
|
-
title: title,
|
471
|
-
"aria-hidden": true
|
472
|
-
}, title));
|
427
|
+
var renderMain = function renderMain() {
|
428
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
429
|
+
ref: innerContentRef,
|
430
|
+
className: (0, _classnames.default)("".concat(blockClass, "__inner-content"), (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__inner-content--static"), !doAnimateTitle), "".concat(blockClass, "--scrolls"), !doAnimateTitle))
|
431
|
+
}, children);
|
473
432
|
};
|
474
|
-
|
475
|
-
(0, _useResizeObserver.useResizeObserver)(contentRef, handleResize);
|
433
|
+
(0, _useResizeObserver.useResizeObserver)(sidePanelRef, handleResize, [open]);
|
476
434
|
return /*#__PURE__*/_react.default.createElement(_framerMotion.AnimatePresence, null, open && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_framerMotion.motion.div, (0, _extends2.default)({}, (0, _devtools.getDevtoolsProps)(componentName), rest, {
|
477
435
|
id: id,
|
478
436
|
className: mainPanelClassNames,
|
479
437
|
onBlur: handleBlur,
|
480
|
-
ref:
|
438
|
+
ref: sidePanelRef,
|
481
439
|
role: "complementary",
|
482
440
|
"aria-label": title,
|
483
441
|
onAnimationComplete: onAnimationEnd,
|
@@ -494,16 +452,14 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
494
452
|
tabIndex: "0",
|
495
453
|
role: "link",
|
496
454
|
className: "".concat(blockClass, "__visually-hidden")
|
497
|
-
}, "Focus sentinel"),
|
498
|
-
ref:
|
499
|
-
className:
|
500
|
-
},
|
501
|
-
className: "".concat(blockClass, "__body-content")
|
502
|
-
}, children), /*#__PURE__*/_react.default.createElement(_ActionSet.ActionSet, {
|
455
|
+
}, "Focus sentinel"), doAnimateTitle ? /*#__PURE__*/_react.default.createElement("div", {
|
456
|
+
ref: animatedScrollRef,
|
457
|
+
className: "".concat(blockClass, "__animated-scroll-wrapper ").concat(blockClass, "--scrolls")
|
458
|
+
}, renderHeader(), renderMain()) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/_react.default.createElement(_ActionSet.ActionSet, {
|
503
459
|
actions: actions,
|
504
460
|
className: primaryActionContainerClassNames,
|
505
461
|
size: size === 'xs' ? 'sm' : size
|
506
|
-
})
|
462
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
507
463
|
ref: endTrapRef,
|
508
464
|
tabIndex: "0",
|
509
465
|
role: "link",
|
@@ -513,7 +469,7 @@ var SidePanel = exports.SidePanel = /*#__PURE__*/_react.default.forwardRef(funct
|
|
513
469
|
initial: "hidden",
|
514
470
|
animate: "visible",
|
515
471
|
exit: "exit",
|
516
|
-
ref:
|
472
|
+
ref: overlayRef,
|
517
473
|
className: "".concat(blockClass, "__overlay")
|
518
474
|
}))));
|
519
475
|
});
|
@@ -628,8 +584,8 @@ SidePanel.propTypes = {
|
|
628
584
|
* This is the selector to the element that contains all of the page content that will shrink if the panel is a slide in.
|
629
585
|
* This prop is required when using the `slideIn` variant of the side panel.
|
630
586
|
*/
|
631
|
-
selectorPageContent: _propTypes.default.string.isRequired.if(function (
|
632
|
-
var slideIn =
|
587
|
+
selectorPageContent: _propTypes.default.string.isRequired.if(function (_ref7) {
|
588
|
+
var slideIn = _ref7.slideIn;
|
633
589
|
return slideIn;
|
634
590
|
}),
|
635
591
|
/**
|
@@ -656,8 +612,8 @@ SidePanel.propTypes = {
|
|
656
612
|
/**
|
657
613
|
* Sets the title text
|
658
614
|
*/
|
659
|
-
title: _propTypes.default.string.isRequired.if(function (
|
660
|
-
var labelText =
|
615
|
+
title: _propTypes.default.string.isRequired.if(function (_ref8) {
|
616
|
+
var labelText = _ref8.labelText;
|
661
617
|
return labelText;
|
662
618
|
})
|
663
619
|
};
|
@@ -22,8 +22,8 @@ var _propsHelper = require("../../global/js/utils/props-helper");
|
|
22
22
|
var _settings = require("../../settings");
|
23
23
|
var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags", "containingElementRef", "measurementOffset"],
|
24
24
|
_excluded2 = ["label", "id"],
|
25
|
-
_excluded3 = ["label"]; //
|
26
|
-
// Copyright IBM Corp. 2020,
|
25
|
+
_excluded3 = ["label", "onClose"]; //
|
26
|
+
// Copyright IBM Corp. 2020, 2024
|
27
27
|
//
|
28
28
|
// This source code is licensed under the Apache-2.0 license found in the
|
29
29
|
// LICENSE file in the root directory of this source tree.
|
@@ -89,6 +89,10 @@ var TagSet = exports.TagSet = /*#__PURE__*/_react.default.forwardRef(function (_
|
|
89
89
|
sizingTags = _useState10[0],
|
90
90
|
setSizingTags = _useState10[1];
|
91
91
|
var overflowTag = (0, _react.useRef)(null);
|
92
|
+
var _useState11 = (0, _react.useState)(false),
|
93
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
94
|
+
popoverOpen = _useState12[0],
|
95
|
+
setPopoverOpen = _useState12[1];
|
92
96
|
var handleShowAllClick = function handleShowAllClick() {
|
93
97
|
setShowAllModalOpen(true);
|
94
98
|
};
|
@@ -112,13 +116,23 @@ var TagSet = exports.TagSet = /*#__PURE__*/_react.default.forwardRef(function (_
|
|
112
116
|
}) : []);
|
113
117
|
setSizingTags(newSizingTags);
|
114
118
|
}, [tags]);
|
119
|
+
var handleTagOnClose = (0, _react.useCallback)(function (onClose, index) {
|
120
|
+
onClose === null || onClose === void 0 || onClose();
|
121
|
+
if (index <= displayCount - 1) {
|
122
|
+
setPopoverOpen(false);
|
123
|
+
}
|
124
|
+
}, [displayCount]);
|
115
125
|
(0, _react.useEffect)(function () {
|
116
126
|
// create visible and overflow tags
|
117
127
|
var newDisplayedTags = tags && tags.length > 0 ? tags.map(function (_ref3, index) {
|
118
128
|
var label = _ref3.label,
|
129
|
+
_onClose = _ref3.onClose,
|
119
130
|
other = (0, _objectWithoutProperties2.default)(_ref3, _excluded3);
|
120
131
|
return /*#__PURE__*/_react.default.createElement(_react2.Tag, (0, _extends2.default)({}, other, {
|
121
|
-
key: "displayed-tag-".concat(index)
|
132
|
+
key: "displayed-tag-".concat(index),
|
133
|
+
onClose: function onClose() {
|
134
|
+
return handleTagOnClose(_onClose, index);
|
135
|
+
}
|
122
136
|
}), label);
|
123
137
|
}) : [];
|
124
138
|
|
@@ -141,10 +155,12 @@ var TagSet = exports.TagSet = /*#__PURE__*/_react.default.forwardRef(function (_
|
|
141
155
|
overflowType: overflowType,
|
142
156
|
showAllTagsLabel: showAllTagsLabel,
|
143
157
|
key: "displayed-tag-overflow",
|
144
|
-
ref: overflowTag
|
158
|
+
ref: overflowTag,
|
159
|
+
popoverOpen: popoverOpen,
|
160
|
+
setPopoverOpen: setPopoverOpen
|
145
161
|
}));
|
146
162
|
setDisplayedTags(newDisplayedTags);
|
147
|
-
}, [displayCount, overflowAlign, overflowClassName, overflowType, showAllTagsLabel, tags]);
|
163
|
+
}, [displayCount, overflowAlign, overflowClassName, overflowType, showAllTagsLabel, tags, popoverOpen, handleTagOnClose]);
|
148
164
|
var checkFullyVisibleTags = (0, _react.useCallback)(function () {
|
149
165
|
if (multiline) {
|
150
166
|
return setDisplayCount(maxVisible);
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
exports.TagSetOverflow = void 0;
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
12
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13
12
|
var _react = _interopRequireWildcard(require("react"));
|
14
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
@@ -16,8 +15,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
15
|
var _react2 = require("@carbon/react");
|
17
16
|
var _hooks = require("../../global/js/hooks");
|
18
17
|
var _settings = require("../../settings");
|
19
|
-
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel"]; //
|
20
|
-
// Copyright IBM Corp. 2021,
|
18
|
+
var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel", "popoverOpen", "setPopoverOpen"]; //
|
19
|
+
// Copyright IBM Corp. 2021, 2024
|
21
20
|
//
|
22
21
|
// This source code is licensed under the Apache-2.0 license found in the
|
23
22
|
// LICENSE file in the root directory of this source tree.
|
@@ -42,11 +41,9 @@ var TagSetOverflow = exports.TagSetOverflow = /*#__PURE__*/_react.default.forwar
|
|
42
41
|
overflowTags = _ref.overflowTags,
|
43
42
|
overflowType = _ref.overflowType,
|
44
43
|
showAllTagsLabel = _ref.showAllTagsLabel,
|
44
|
+
popoverOpen = _ref.popoverOpen,
|
45
|
+
setPopoverOpen = _ref.setPopoverOpen,
|
45
46
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
46
|
-
var _useState = (0, _react.useState)(false),
|
47
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
48
|
-
popoverOpen = _useState2[0],
|
49
|
-
setPopoverOpen = _useState2[1];
|
50
47
|
var localRef = (0, _react.useRef)();
|
51
48
|
var overflowTagContent = (0, _react.useRef)(null);
|
52
49
|
(0, _hooks.useClickOutside)(ref || localRef, function () {
|
@@ -90,7 +87,6 @@ var TagSetOverflow = exports.TagSetOverflow = /*#__PURE__*/_react.default.forwar
|
|
90
87
|
}, overflowTags.filter(function (_, index) {
|
91
88
|
return overflowTags.length > allTagsModalSearchThreshold ? index < allTagsModalSearchThreshold : index <= allTagsModalSearchThreshold;
|
92
89
|
}).map(function (tag, index) {
|
93
|
-
var _cx2;
|
94
90
|
var tagProps = {};
|
95
91
|
if (overflowType === 'tag') {
|
96
92
|
tagProps.type = 'high-contrast';
|
@@ -99,7 +95,7 @@ var TagSetOverflow = exports.TagSetOverflow = /*#__PURE__*/_react.default.forwar
|
|
99
95
|
tagProps.filter = false;
|
100
96
|
}
|
101
97
|
return /*#__PURE__*/_react.default.createElement("li", {
|
102
|
-
className: (0, _classnames.default)("".concat(blockClass, "__tag-item"), (
|
98
|
+
className: (0, _classnames.default)("".concat(blockClass, "__tag-item"), (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__tag-item--default"), overflowType === 'default'), "".concat(blockClass, "__tag-item--tag"), overflowType === 'tag')),
|
103
99
|
key: index
|
104
100
|
}, /*#__PURE__*/_react.default.cloneElement(tag, tagProps));
|
105
101
|
})), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/_react.default.createElement(_react2.Link, {
|
@@ -135,6 +131,14 @@ TagSetOverflow.propTypes = {
|
|
135
131
|
* Type of rendering displayed inside of the tag overflow component
|
136
132
|
*/
|
137
133
|
overflowType: _propTypes.default.oneOf(['default', 'tag']),
|
134
|
+
/**
|
135
|
+
* Open state of the popover
|
136
|
+
*/
|
137
|
+
popoverOpen: _propTypes.default.bool,
|
138
|
+
/**
|
139
|
+
* Setter function for the popoverOpen state value
|
140
|
+
*/
|
141
|
+
setPopoverOpen: _propTypes.default.func,
|
138
142
|
/**
|
139
143
|
* label for the overflow show all tags link
|
140
144
|
*/
|