@carbon/ibm-products 2.26.0 → 2.27.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +517 -56
- 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 +32 -14
- 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 +517 -56
- 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 +488 -48
- 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/BigNumbers/BigNumbers.d.ts +11 -0
- package/es/components/BigNumbers/BigNumbers.js +238 -0
- package/es/components/BigNumbers/constants.d.ts +13 -0
- package/es/components/BigNumbers/constants.js +67 -0
- package/es/components/BigNumbers/index.d.ts +1 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
- package/es/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
- package/es/components/DataSpreadsheet/utils/checkForHoldingKey.js +17 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +9 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +8 -4
- package/es/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +21 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +32 -9
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +35 -3
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +1 -1
- package/es/components/Datagrid/useSelectAllToggle.js +5 -3
- package/es/components/SidePanel/SidePanel.js +13 -6
- package/es/components/SidePanel/motion/variants.d.ts +39 -12
- package/es/components/SidePanel/motion/variants.js +42 -11
- package/es/components/StringFormatter/StringFormatter.d.ts +6 -0
- package/es/components/StringFormatter/StringFormatter.js +79 -0
- package/es/components/StringFormatter/index.d.ts +1 -0
- package/es/components/StringFormatter/utils/enums.d.ts +14 -0
- package/es/components/StringFormatter/utils/enums.js +23 -0
- package/es/components/Tearsheet/TearsheetShell.js +10 -4
- package/es/components/UserAvatar/UserAvatar.js +58 -42
- package/es/components/index.d.ts +2 -0
- package/es/global/js/hooks/index.d.ts +1 -0
- package/es/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
- package/es/global/js/hooks/useIsomorphicEffect.js +14 -0
- package/es/global/js/package-settings.d.ts +2 -0
- package/es/global/js/package-settings.js +2 -0
- package/es/index.js +2 -0
- package/es/settings.d.ts +2 -0
- package/lib/components/BigNumbers/BigNumbers.d.ts +11 -0
- package/lib/components/BigNumbers/BigNumbers.js +244 -0
- package/lib/components/BigNumbers/constants.d.ts +13 -0
- package/lib/components/BigNumbers/constants.js +76 -0
- package/lib/components/BigNumbers/index.d.ts +1 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
- package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
- package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.js +21 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +9 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +8 -4
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +20 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +30 -7
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +33 -1
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +1 -1
- package/lib/components/Datagrid/useSelectAllToggle.js +4 -2
- package/lib/components/SidePanel/SidePanel.js +11 -4
- package/lib/components/SidePanel/motion/variants.d.ts +39 -12
- package/lib/components/SidePanel/motion/variants.js +42 -10
- package/lib/components/StringFormatter/StringFormatter.d.ts +6 -0
- package/lib/components/StringFormatter/StringFormatter.js +85 -0
- package/lib/components/StringFormatter/index.d.ts +1 -0
- package/lib/components/StringFormatter/utils/enums.d.ts +14 -0
- package/lib/components/StringFormatter/utils/enums.js +27 -0
- package/lib/components/Tearsheet/TearsheetShell.js +10 -4
- package/lib/components/UserAvatar/UserAvatar.js +58 -42
- package/lib/components/index.d.ts +2 -0
- package/lib/global/js/hooks/index.d.ts +1 -0
- package/lib/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
- package/lib/global/js/hooks/useIsomorphicEffect.js +18 -0
- package/lib/global/js/package-settings.d.ts +2 -0
- package/lib/global/js/package-settings.js +2 -0
- package/lib/index.js +10 -0
- package/lib/settings.d.ts +2 -0
- package/package.json +7 -7
- package/scss/components/BigNumbers/_big-numbers.scss +151 -0
- package/scss/components/BigNumbers/_carbon-imports.scss +11 -0
- package/scss/components/BigNumbers/_index-with-carbon.scss +9 -0
- package/scss/components/BigNumbers/_index.scss +8 -0
- package/scss/components/FullPageError/_full-page-error.scss +2 -2
- package/scss/components/SidePanel/_side-panel.scss +1 -1
- package/scss/components/StringFormatter/_carbon-imports.scss +10 -0
- package/scss/components/StringFormatter/_index-with-carbon.scss +9 -0
- package/scss/components/StringFormatter/_index.scss +8 -0
- package/scss/components/StringFormatter/_string-formatter.scss +97 -0
- package/scss/components/Tearsheet/_tearsheet.scss +34 -2
- package/scss/components/UserAvatar/_user-avatar.scss +40 -0
- package/scss/components/_index-with-carbon.scss +2 -0
- package/scss/components/_index.scss +2 -0
@@ -6,9 +6,9 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import React__default, { createContext, useState } from 'react';
|
9
|
+
import React__default, { createContext, useState, useReducer } from 'react';
|
10
10
|
import PropTypes from '../../../../../node_modules/prop-types/index.js';
|
11
|
-
import { DROPDOWN, RADIO, NUMBER, DATE, CHECKBOX, CLEAR_SINGLE_FILTER } from './constants.js';
|
11
|
+
import { DROPDOWN, RADIO, NUMBER, DATE, CHECKBOX, SAVED_FILTERS, CLEAR_SINGLE_FILTER } from './constants.js';
|
12
12
|
|
13
13
|
var FilterContext = /*#__PURE__*/createContext();
|
14
14
|
var EventEmitter = {
|
@@ -139,22 +139,45 @@ var prepareFiltersForTags = function prepareFiltersForTags(filters, renderDateLa
|
|
139
139
|
});
|
140
140
|
return tags;
|
141
141
|
};
|
142
|
-
var
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
142
|
+
var filteringReducer = function filteringReducer(state, action) {
|
143
|
+
switch (action.type) {
|
144
|
+
case SAVED_FILTERS:
|
145
|
+
{
|
146
|
+
var _ref3 = action.payload || {},
|
147
|
+
savedFilters = _ref3.savedFilters;
|
148
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
149
|
+
savedFilters: savedFilters
|
150
|
+
});
|
151
|
+
}
|
152
|
+
default:
|
153
|
+
return state;
|
154
|
+
}
|
155
|
+
};
|
156
|
+
var FilterProvider = function FilterProvider(_ref4) {
|
157
|
+
var children = _ref4.children,
|
158
|
+
filters = _ref4.filters,
|
159
|
+
filterProps = _ref4.filterProps;
|
160
|
+
var _ref5 = filterProps || {},
|
161
|
+
renderDateLabel = _ref5.renderDateLabel;
|
148
162
|
var filterTags = prepareFiltersForTags(filters, renderDateLabel);
|
149
163
|
var _useState = useState(false),
|
150
164
|
_useState2 = _slicedToArray(_useState, 2),
|
151
165
|
panelOpen = _useState2[0],
|
152
166
|
setPanelOpen = _useState2[1];
|
167
|
+
var initialState = {
|
168
|
+
savedFilters: []
|
169
|
+
};
|
170
|
+
var _useReducer = useReducer(filteringReducer, initialState),
|
171
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
172
|
+
state = _useReducer2[0],
|
173
|
+
dispatch = _useReducer2[1];
|
153
174
|
var value = {
|
154
175
|
filterTags: filterTags,
|
155
176
|
EventEmitter: EventEmitter,
|
156
177
|
panelOpen: panelOpen,
|
157
|
-
setPanelOpen: setPanelOpen
|
178
|
+
setPanelOpen: setPanelOpen,
|
179
|
+
state: state,
|
180
|
+
dispatch: dispatch
|
158
181
|
};
|
159
182
|
return /*#__PURE__*/React__default.createElement(FilterContext.Provider, {
|
160
183
|
value: value
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright IBM Corp. 2022,
|
2
|
+
* Copyright IBM Corp. 2022, 2024
|
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.
|
@@ -22,3 +22,5 @@ export const CLEAR_SINGLE_FILTER: "clearSingleFilter";
|
|
22
22
|
/** Constants for panel dimensions */
|
23
23
|
export const PANEL_WIDTH: 320;
|
24
24
|
export const ACTION_SET_HEIGHT: 64;
|
25
|
+
/** Constants for local reducer */
|
26
|
+
export const SAVED_FILTERS: "savedFilters";
|
@@ -28,4 +28,7 @@ var CLEAR_SINGLE_FILTER = 'clearSingleFilter';
|
|
28
28
|
var PANEL_WIDTH = 320;
|
29
29
|
var ACTION_SET_HEIGHT = 64;
|
30
30
|
|
31
|
-
|
31
|
+
/** Constants for local reducer */
|
32
|
+
var SAVED_FILTERS = 'savedFilters';
|
33
|
+
|
34
|
+
export { ACTION_SET_HEIGHT, BATCH, CHECKBOX, CLEAR_FILTERS, CLEAR_SINGLE_FILTER, DATE, DROPDOWN, FLYOUT, INSTANT, NUMBER, PANEL, PANEL_WIDTH, RADIO, SAVED_FILTERS };
|
@@ -6,11 +6,12 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { slicedToArray as _slicedToArray, extends as _extends, toConsumableArray as _toConsumableArray, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import { DROPDOWN, RADIO, CHECKBOX, NUMBER, DATE, BATCH, INSTANT, PANEL } from '../constants.js';
|
9
|
+
import { DROPDOWN, RADIO, CHECKBOX, NUMBER, DATE, BATCH, SAVED_FILTERS, INSTANT, PANEL } from '../constants.js';
|
10
10
|
import { Dropdown, FormGroup, RadioButtonGroup, RadioButton, NumberInput, DatePicker, DatePickerInput, Layer, Checkbox } from '@carbon/react';
|
11
|
-
import React__default, { useState, useRef, useCallback, useEffect } from 'react';
|
11
|
+
import React__default, { useContext, useState, useRef, useCallback, useEffect } from 'react';
|
12
12
|
import OverflowCheckboxes from '../OverflowCheckboxes.js';
|
13
13
|
import { getInitialStateFromFilters } from '../utils.js';
|
14
|
+
import { FilterContext } from '../FilterProvider.js';
|
14
15
|
import { handleCheckboxChange } from '../handleCheckboxChange.js';
|
15
16
|
import { usePreviousValue } from '../../../../../../global/js/hooks/usePreviousValue.js';
|
16
17
|
|
@@ -25,6 +26,10 @@ var useFilters = function useFilters(_ref) {
|
|
25
26
|
panelOpen = _ref.panelOpen,
|
26
27
|
autoHideFilters = _ref.autoHideFilters,
|
27
28
|
isFetching = _ref.isFetching;
|
29
|
+
var _useContext = useContext(FilterContext),
|
30
|
+
state = _useContext.state,
|
31
|
+
localDispatch = _useContext.dispatch;
|
32
|
+
var savedFilters = state.savedFilters;
|
28
33
|
/** State */
|
29
34
|
var _useState = useState(getInitialStateFromFilters(filters, variation, reactTableFiltersState)),
|
30
35
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -122,6 +127,16 @@ var useFilters = function useFilters(_ref) {
|
|
122
127
|
filterCopy.splice(index, 1);
|
123
128
|
}
|
124
129
|
setFiltersObjectArray(filterCopy);
|
130
|
+
|
131
|
+
// Dispatch action from local filter context to track filters in order
|
132
|
+
// to keep history if `isFetching` becomes true. If so, react-table
|
133
|
+
// clears all filter history
|
134
|
+
localDispatch({
|
135
|
+
type: SAVED_FILTERS,
|
136
|
+
payload: {
|
137
|
+
savedFilters: filterCopy
|
138
|
+
}
|
139
|
+
});
|
125
140
|
if (updateMethod === INSTANT) {
|
126
141
|
setAllFilters(filterCopy);
|
127
142
|
}
|
@@ -312,10 +327,27 @@ var useFilters = function useFilters(_ref) {
|
|
312
327
|
setAllFilters(JSON.parse(prevFiltersObjectArrayRef.current));
|
313
328
|
setFetchingReset(true);
|
314
329
|
}
|
330
|
+
if (isFetching && fetchingReset) {
|
331
|
+
var cleanFilters = function cleanFilters(originalFilterState) {
|
332
|
+
var copy = _objectSpread2({}, originalFilterState);
|
333
|
+
var updatedFilters = savedFilters.map(function (f) {
|
334
|
+
if (Object.hasOwn(copy, f.id)) {
|
335
|
+
copy[f.id] = f;
|
336
|
+
return copy;
|
337
|
+
}
|
338
|
+
return copy;
|
339
|
+
});
|
340
|
+
return updatedFilters[0];
|
341
|
+
};
|
342
|
+
setFiltersObjectArray(savedFilters);
|
343
|
+
var filterStateCopy = cleanFilters(filtersState);
|
344
|
+
setFiltersState(filterStateCopy);
|
345
|
+
}
|
315
346
|
if (!isFetching) {
|
316
347
|
setFetchingReset(false);
|
317
348
|
}
|
318
|
-
|
349
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
350
|
+
}, [isFetching, reactTableFiltersState, setAllFilters, fetchingReset, savedFilters, filtersObjectArray]);
|
319
351
|
var cancel = function cancel() {
|
320
352
|
// Reverting to previous filters only applies when using batch actions
|
321
353
|
if (updateMethod === BATCH) {
|
@@ -116,7 +116,7 @@ var stateReducer = function stateReducer(newState, action) {
|
|
116
116
|
var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref5) {
|
117
117
|
var _ref6 = _slicedToArray(_ref5, 1),
|
118
118
|
key = _ref6[0];
|
119
|
-
return parseInt(key) !== parseInt(rowData.index);
|
119
|
+
return parseInt(key) !== parseInt(_getRowId(rowData.original, rowData.index));
|
120
120
|
}));
|
121
121
|
return _objectSpread2(_objectSpread2({}, newState), {}, {
|
122
122
|
selectedRowData: dataWithRemovedRow
|
@@ -6,11 +6,12 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import React__default, { useState
|
9
|
+
import React__default, { useState } from 'react';
|
10
10
|
import cx from '../../node_modules/classnames/index.js';
|
11
11
|
import { selectionColumnId } from './common-column-ids.js';
|
12
12
|
import SelectAllWithToggle from './Datagrid/DatagridSelectAllWithToggle.js';
|
13
13
|
import { pkg } from '../../settings.js';
|
14
|
+
import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
|
14
15
|
|
15
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid__select-all");
|
16
17
|
var useSelectAllToggle = function useSelectAllToggle(hooks) {
|
@@ -36,11 +37,12 @@ var useSelectAllWithToggleComponent = function useSelectAllWithToggleComponent(h
|
|
36
37
|
hooks.useInstance.push(useInstance);
|
37
38
|
};
|
38
39
|
var useAddClassNameToSelectRow = function useAddClassNameToSelectRow(hooks) {
|
39
|
-
var _useState = useState(
|
40
|
+
var _useState = useState(0),
|
40
41
|
_useState2 = _slicedToArray(_useState, 2),
|
41
42
|
windowSize = _useState2[0],
|
42
43
|
setWindowSize = _useState2[1];
|
43
|
-
|
44
|
+
useIsomorphicEffect(function () {
|
45
|
+
setWindowSize(window.innerWidth);
|
44
46
|
function updateSize() {
|
45
47
|
setWindowSize(window.innerWidth);
|
46
48
|
}
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import React__default, { useState, useRef, useEffect, useCallback } from 'react';
|
10
|
-
import {
|
10
|
+
import { motion, useReducedMotion, AnimatePresence } from 'framer-motion';
|
11
11
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
12
12
|
import cx from '../../node_modules/classnames/index.js';
|
13
13
|
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
|
@@ -19,10 +19,10 @@ import { pkg } from '../../settings.js';
|
|
19
19
|
import { SIDE_PANEL_SIZES } from './constants.js';
|
20
20
|
import { Button } from '@carbon/react';
|
21
21
|
import { ArrowLeft, Close } from '@carbon/react/icons';
|
22
|
-
import { overlayVariants, panelVariants } from './motion/variants.js';
|
22
|
+
import { actionSetVariants, overlayVariants, panelVariants } from './motion/variants.js';
|
23
23
|
import pconsole from '../../global/js/utils/pconsole.js';
|
24
|
-
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
25
24
|
import { ActionSet } from '../ActionSet/ActionSet.js';
|
25
|
+
import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
26
26
|
|
27
27
|
var _excluded = ["actionToolbarButtons", "actions", "animateTitle", "children", "className", "closeIconDescription", "condensedActions", "currentStep", "id", "includeOverlay", "labelText", "navigationBackIconDescription", "onNavigationBack", "onRequestClose", "onUnmount", "open", "placement", "preventCloseOnClickOutside", "selectorPageContent", "selectorPrimaryFocus", "size", "slideIn", "slug", "subtitle", "title"],
|
28
28
|
_excluded2 = ["label", "kind", "icon", "tooltipPosition", "tooltipAlignment", "leading", "disabled", "className", "onClick"];
|
@@ -40,6 +40,7 @@ var defaults = {
|
|
40
40
|
placement: 'right',
|
41
41
|
size: 'md'
|
42
42
|
};
|
43
|
+
var MotionActionSet = motion(ActionSet);
|
43
44
|
|
44
45
|
/**
|
45
46
|
* Side panels keep users in-context of a page while performing tasks like navigating, editing, viewing details, or configuring something new.
|
@@ -107,6 +108,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
107
108
|
_useState6 = _slicedToArray(_useState5, 2),
|
108
109
|
doAnimateTitle = _useState6[0],
|
109
110
|
setDoAnimateTitle = _useState6[1];
|
111
|
+
var shouldReduceMotion = useReducedMotion();
|
110
112
|
useEffect(function () {
|
111
113
|
setDoAnimateTitle(animateTitle);
|
112
114
|
}, [animateTitle]);
|
@@ -429,7 +431,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
429
431
|
initial: "hidden",
|
430
432
|
animate: "visible",
|
431
433
|
exit: "exit",
|
432
|
-
custom:
|
434
|
+
custom: {
|
435
|
+
placement: placement,
|
436
|
+
shouldReduceMotion: shouldReduceMotion
|
437
|
+
}
|
433
438
|
}), /*#__PURE__*/React__default.createElement("span", {
|
434
439
|
ref: startTrapRef,
|
435
440
|
tabIndex: "0",
|
@@ -438,10 +443,12 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
438
443
|
}, "Focus sentinel"), doAnimateTitle ? /*#__PURE__*/React__default.createElement("div", {
|
439
444
|
ref: animatedScrollRef,
|
440
445
|
className: "".concat(blockClass, "__animated-scroll-wrapper ").concat(blockClass, "--scrolls")
|
441
|
-
}, renderHeader(), renderMain()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(
|
446
|
+
}, renderHeader(), renderMain()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(MotionActionSet, {
|
442
447
|
actions: actions,
|
443
448
|
className: primaryActionContainerClassNames,
|
444
|
-
size: size === 'xs' ? 'sm' : size
|
449
|
+
size: size === 'xs' ? 'sm' : size,
|
450
|
+
custom: shouldReduceMotion,
|
451
|
+
variants: actionSetVariants
|
445
452
|
}), /*#__PURE__*/React__default.createElement("span", {
|
446
453
|
ref: endTrapRef,
|
447
454
|
tabIndex: "0",
|
@@ -16,27 +16,54 @@ export namespace overlayVariants {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
export namespace panelVariants {
|
19
|
-
export
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
28
|
-
}
|
19
|
+
export function visible_1({ shouldReduceMotion }: {
|
20
|
+
shouldReduceMotion: any;
|
21
|
+
}): {
|
22
|
+
x: number;
|
23
|
+
transition: {
|
24
|
+
duration: number;
|
25
|
+
ease: number[];
|
26
|
+
};
|
27
|
+
opacity: any;
|
28
|
+
};
|
29
29
|
export { visible_1 as visible };
|
30
|
-
export function hidden_1(placement
|
30
|
+
export function hidden_1({ placement, shouldReduceMotion }: {
|
31
|
+
placement: any;
|
32
|
+
shouldReduceMotion: any;
|
33
|
+
}): {
|
31
34
|
x: string | number;
|
35
|
+
opacity: any;
|
32
36
|
};
|
33
37
|
export { hidden_1 as hidden };
|
34
|
-
export function exit_1(placement
|
38
|
+
export function exit_1({ placement, shouldReduceMotion }: {
|
39
|
+
placement: any;
|
40
|
+
shouldReduceMotion: any;
|
41
|
+
}): {
|
35
42
|
x: string | number;
|
36
43
|
transition: {
|
37
44
|
duration: number;
|
38
45
|
ease: number[];
|
39
46
|
};
|
47
|
+
opacity: any;
|
40
48
|
};
|
41
49
|
export { exit_1 as exit };
|
42
50
|
}
|
51
|
+
export namespace actionSetVariants {
|
52
|
+
export function hidden_2(shouldReduceMotion: any): {
|
53
|
+
opacity: number;
|
54
|
+
transition: {
|
55
|
+
duration: number;
|
56
|
+
ease: number | number[];
|
57
|
+
};
|
58
|
+
};
|
59
|
+
export { hidden_2 as hidden };
|
60
|
+
export function visible_2(shouldReduceMotion: any): {
|
61
|
+
opacity: number;
|
62
|
+
transition: {
|
63
|
+
duration: number;
|
64
|
+
ease: number | number[];
|
65
|
+
delay: number;
|
66
|
+
};
|
67
|
+
};
|
68
|
+
export { visible_2 as visible };
|
69
|
+
}
|
@@ -23,27 +23,58 @@ var overlayVariants = {
|
|
23
23
|
}
|
24
24
|
};
|
25
25
|
var panelVariants = {
|
26
|
-
visible: {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
visible: function visible(_ref) {
|
27
|
+
var shouldReduceMotion = _ref.shouldReduceMotion;
|
28
|
+
return {
|
29
|
+
x: 0,
|
30
|
+
transition: {
|
31
|
+
duration: DURATIONS.moderate02,
|
32
|
+
ease: EASINGS.productive.standard
|
33
|
+
},
|
34
|
+
opacity: shouldReduceMotion && 1
|
35
|
+
};
|
32
36
|
},
|
33
|
-
hidden: function hidden(
|
37
|
+
hidden: function hidden(_ref2) {
|
38
|
+
var placement = _ref2.placement,
|
39
|
+
shouldReduceMotion = _ref2.shouldReduceMotion;
|
34
40
|
return {
|
35
|
-
x: placement === 'right' ? '100%' : -320
|
41
|
+
x: placement === 'right' ? shouldReduceMotion ? 0 : '100%' : shouldReduceMotion ? 0 : -320,
|
42
|
+
opacity: shouldReduceMotion && 0
|
36
43
|
};
|
37
44
|
},
|
38
|
-
exit: function exit(
|
45
|
+
exit: function exit(_ref3) {
|
46
|
+
var placement = _ref3.placement,
|
47
|
+
shouldReduceMotion = _ref3.shouldReduceMotion;
|
39
48
|
return {
|
40
|
-
x: placement === 'right' ? '100%' : -320,
|
49
|
+
x: placement === 'right' ? shouldReduceMotion ? 0 : '100%' : shouldReduceMotion ? 0 : -320,
|
41
50
|
transition: {
|
42
51
|
duration: DURATIONS.moderate01,
|
43
52
|
ease: EASINGS.productive.exit
|
53
|
+
},
|
54
|
+
opacity: shouldReduceMotion && 0
|
55
|
+
};
|
56
|
+
}
|
57
|
+
};
|
58
|
+
var actionSetVariants = {
|
59
|
+
hidden: function hidden(shouldReduceMotion) {
|
60
|
+
return {
|
61
|
+
opacity: shouldReduceMotion ? 0 : 1,
|
62
|
+
transition: {
|
63
|
+
duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast01,
|
64
|
+
ease: shouldReduceMotion ? 0 : EASINGS.productive.exit
|
65
|
+
}
|
66
|
+
};
|
67
|
+
},
|
68
|
+
visible: function visible(shouldReduceMotion) {
|
69
|
+
return {
|
70
|
+
opacity: 1,
|
71
|
+
transition: {
|
72
|
+
duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast02,
|
73
|
+
ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance,
|
74
|
+
delay: shouldReduceMotion ? 0.075 : 0
|
44
75
|
}
|
45
76
|
};
|
46
77
|
}
|
47
78
|
};
|
48
79
|
|
49
|
-
export { overlayVariants, panelVariants };
|
80
|
+
export { actionSetVariants, overlayVariants, panelVariants };
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* StringFormatter allows for truncating text while displaying a tooltip
|
3
|
+
* overlay on hover or focus with the entirety of the provided copy.
|
4
|
+
*/
|
5
|
+
export let StringFormatter: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
6
|
+
import React from 'react';
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
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 { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default from 'react';
|
10
|
+
import PropTypes from '../../node_modules/prop-types/index.js';
|
11
|
+
import cx from '../../node_modules/classnames/index.js';
|
12
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
13
|
+
import { pkg } from '../../settings.js';
|
14
|
+
import { DefinitionTooltip } from '@carbon/react';
|
15
|
+
import { StringFormatterAlignment } from './utils/enums.js';
|
16
|
+
|
17
|
+
var _excluded = ["className", "lines", "tooltipDirection", "truncate", "width", "value"];
|
18
|
+
var blockClass = "".concat(pkg.prefix, "--string-formatter");
|
19
|
+
var componentName = 'StringFormatter';
|
20
|
+
var defaults = {
|
21
|
+
lines: 1,
|
22
|
+
tooltipDirection: StringFormatterAlignment.BOTTOM_LEFT,
|
23
|
+
truncate: false,
|
24
|
+
width: null
|
25
|
+
};
|
26
|
+
|
27
|
+
/**
|
28
|
+
* StringFormatter allows for truncating text while displaying a tooltip
|
29
|
+
* overlay on hover or focus with the entirety of the provided copy.
|
30
|
+
*/
|
31
|
+
var StringFormatter = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
32
|
+
var className = _ref.className,
|
33
|
+
_ref$lines = _ref.lines,
|
34
|
+
lines = _ref$lines === void 0 ? defaults.lines : _ref$lines,
|
35
|
+
_ref$tooltipDirection = _ref.tooltipDirection,
|
36
|
+
tooltipDirection = _ref$tooltipDirection === void 0 ? defaults.tooltipDirection : _ref$tooltipDirection,
|
37
|
+
_ref$truncate = _ref.truncate,
|
38
|
+
truncate = _ref$truncate === void 0 ? defaults.truncate : _ref$truncate,
|
39
|
+
_ref$width = _ref.width,
|
40
|
+
width = _ref$width === void 0 ? defaults.width : _ref$width,
|
41
|
+
value = _ref.value,
|
42
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
43
|
+
var stringFormatterContent = /*#__PURE__*/React__default.createElement("span", {
|
44
|
+
className: cx("".concat(blockClass, "--content"), _defineProperty({}, "".concat(blockClass, "--truncate"), truncate)),
|
45
|
+
style: {
|
46
|
+
maxWidth: width,
|
47
|
+
WebkitLineClamp: lines
|
48
|
+
}
|
49
|
+
}, value);
|
50
|
+
return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
|
51
|
+
className: cx(blockClass, className),
|
52
|
+
ref: ref
|
53
|
+
}, getDevtoolsProps(componentName)), truncate ? /*#__PURE__*/React__default.createElement(DefinitionTooltip, {
|
54
|
+
className: "".concat(blockClass, "__tooltip"),
|
55
|
+
align: tooltipDirection,
|
56
|
+
definition: value,
|
57
|
+
openOnHover: true
|
58
|
+
}, stringFormatterContent) : stringFormatterContent);
|
59
|
+
});
|
60
|
+
StringFormatter = pkg.checkComponentEnabled(StringFormatter, componentName);
|
61
|
+
StringFormatter.displayName = componentName;
|
62
|
+
StringFormatter.propTypes = {
|
63
|
+
/**
|
64
|
+
* Provide an optional class to be applied to the containing node.
|
65
|
+
*/
|
66
|
+
className: PropTypes.string,
|
67
|
+
/** Number of lines to clamp value. */
|
68
|
+
lines: PropTypes.number,
|
69
|
+
/** Specify the direction of the tooltip. Can be either top or bottom. */
|
70
|
+
tooltipDirection: PropTypes.oneOf(Object.values(StringFormatterAlignment)),
|
71
|
+
/** Whether or not the value should be truncated. */
|
72
|
+
truncate: PropTypes.bool,
|
73
|
+
/** Value to format. */
|
74
|
+
value: PropTypes.string.isRequired,
|
75
|
+
/** Maximum width of value which should include */
|
76
|
+
width: PropTypes.string
|
77
|
+
};
|
78
|
+
|
79
|
+
export { StringFormatter };
|
@@ -0,0 +1 @@
|
|
1
|
+
export { StringFormatter } from "./StringFormatter";
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export namespace StringFormatterAlignment {
|
2
|
+
let TOP: string;
|
3
|
+
let TOP_LEFT: string;
|
4
|
+
let TOP_RIGHT: string;
|
5
|
+
let BOTTOM: string;
|
6
|
+
let BOTTOM_LEFT: string;
|
7
|
+
let BOTTOM_RIGHT: string;
|
8
|
+
let LEFT: string;
|
9
|
+
let LEFT_BOTTOM: string;
|
10
|
+
let LEFT_TOP: string;
|
11
|
+
let RIGHT: string;
|
12
|
+
let RIGHT_BOTTOM: string;
|
13
|
+
let RIGHT_TOP: string;
|
14
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
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
|
+
var StringFormatterAlignment = {
|
9
|
+
TOP: 'top',
|
10
|
+
TOP_LEFT: 'top-left',
|
11
|
+
TOP_RIGHT: 'top-right',
|
12
|
+
BOTTOM: 'bottom',
|
13
|
+
BOTTOM_LEFT: 'bottom-left',
|
14
|
+
BOTTOM_RIGHT: 'bottom-right',
|
15
|
+
LEFT: 'left',
|
16
|
+
LEFT_BOTTOM: 'left-bottom',
|
17
|
+
LEFT_TOP: 'left-top',
|
18
|
+
RIGHT: 'right',
|
19
|
+
RIGHT_BOTTOM: 'right-bottom',
|
20
|
+
RIGHT_TOP: 'right-top'
|
21
|
+
};
|
22
|
+
|
23
|
+
export { StringFormatterAlignment };
|
@@ -19,7 +19,7 @@ import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
|
|
19
19
|
import { useFocus } from '../../global/js/hooks/useFocus.js';
|
20
20
|
import { ActionSet } from '../ActionSet/ActionSet.js';
|
21
21
|
|
22
|
-
var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "selectorPrimaryFocus", "size", "
|
22
|
+
var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "size", "slug", "title", "verticalPosition"];
|
23
23
|
|
24
24
|
// The block part of our conventional BEM class names (bc__E--M).
|
25
25
|
var bc = "".concat(pkg.prefix, "--tearsheet");
|
@@ -71,9 +71,10 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
71
71
|
navigation = _ref.navigation,
|
72
72
|
onClose = _ref.onClose,
|
73
73
|
open = _ref.open,
|
74
|
+
portalTargetIn = _ref.portalTarget,
|
74
75
|
selectorPrimaryFocus = _ref.selectorPrimaryFocus,
|
75
76
|
size = _ref.size,
|
76
|
-
|
77
|
+
slug = _ref.slug,
|
77
78
|
title = _ref.title,
|
78
79
|
verticalPosition = _ref.verticalPosition,
|
79
80
|
rest = _objectWithoutProperties(_ref, _excluded);
|
@@ -190,9 +191,10 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
190
191
|
var includeActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
|
191
192
|
return renderPortalUse( /*#__PURE__*/React__default.createElement(ComposedModal, _extends({}, rest, {
|
192
193
|
"aria-label": ariaLabel || getNodeTextContent(title),
|
193
|
-
className: cx(bc, className, _defineProperty(_defineProperty(_defineProperty({}, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth),
|
194
|
+
className: cx(bc, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth),
|
194
195
|
// Don't apply this on the initial open of a single tearsheet.
|
195
|
-
depth > 1 || depth === 1 && prevDepth.current > 1), "".concat(bc, "--wide"), wide), "".concat(bc, "--narrow"), !wide)),
|
196
|
+
depth > 1 || depth === 1 && prevDepth.current > 1), "".concat(bc, "--wide"), wide), "".concat(bc, "--narrow"), !wide), "".concat(bc, "--has-slug"), slug), "".concat(bc, "--has-close"), effectiveHasCloseIcon)),
|
197
|
+
slug: slug,
|
196
198
|
style: _defineProperty(_defineProperty({}, "--".concat(bc, "--stacking-scale-factor-single"), (width - 32) / width), "--".concat(bc, "--stacking-scale-factor-double"), (width - 64) / width),
|
197
199
|
containerClassName: cx("".concat(bc, "__container"), _defineProperty({}, "".concat(bc, "__container--lower"), verticalPosition === 'lower')),
|
198
200
|
onClose: onClose,
|
@@ -394,6 +396,10 @@ TearsheetShell.propTypes = _objectSpread2({
|
|
394
396
|
* Specifies the width of the tearsheet, 'narrow' or 'wide'.
|
395
397
|
*/
|
396
398
|
size: PropTypes.oneOf(['narrow', 'wide']).isRequired,
|
399
|
+
/**
|
400
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
|
401
|
+
*/
|
402
|
+
slug: PropTypes.node,
|
397
403
|
/**
|
398
404
|
* The main title of the tearsheet, displayed in the header area.
|
399
405
|
*/
|