@carbon/ibm-products 2.35.0 → 2.36.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +957 -567
- 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 +67 -74
- 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 +227 -206
- 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 +443 -247
- 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/Carousel/Carousel.d.ts +46 -2
- package/es/components/Carousel/Carousel.js +36 -21
- package/es/components/Carousel/CarouselItem.d.ts +19 -2
- package/es/components/Carousel/CarouselItem.js +0 -1
- package/es/components/Coachmark/utils/enums.d.ts +36 -22
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.d.ts +26 -2
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +1 -3
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.d.ts +28 -2
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +0 -1
- package/es/components/ConditionBuilder/assets/sampleInput.d.ts +5 -5
- package/es/components/CreateFullPage/CreateFullPage.d.ts +121 -4
- package/es/components/CreateFullPage/CreateFullPage.js +12 -8
- package/es/components/CreateTearsheet/CreateTearsheet.js +2 -0
- package/es/components/Datagrid/Datagrid/DatagridRow.js +4 -3
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +2 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +10 -6
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -2
- package/es/components/EditFullPage/EditFullPage.d.ts +19 -2
- package/es/components/EditFullPage/EditFullPage.js +3 -3
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -3
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -2
- package/es/components/FullPageError/FullPageError.d.ts +2 -1
- package/es/components/FullPageError/FullPageError.js +24 -49
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.d.ts +40 -2
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +1 -1
- package/es/components/InlineTip/InlineTipLink.d.ts +19 -2
- package/es/components/InterstitialScreenView/InterstitialScreenView.d.ts +23 -2
- package/es/components/InterstitialScreenView/InterstitialScreenView.js +0 -1
- package/es/components/InterstitialScreenViewModule/InterstitialScreenViewModule.d.ts +23 -2
- package/es/components/NonLinearReading/NonLinearReading.d.ts +28 -2
- package/es/components/NonLinearReading/NonLinearReading.js +2 -7
- package/es/components/SearchBar/SearchBar.d.ts +51 -3
- package/es/components/SearchBar/SearchBar.js +5 -6
- package/es/components/SidePanel/SidePanel.js +10 -5
- package/es/components/TruncatedList/TruncatedList.d.ts +47 -2
- package/es/components/TruncatedList/TruncatedList.js +5 -4
- package/es/components/UserProfileImage/UserProfileImage.d.ts +66 -2
- package/es/components/UserProfileImage/UserProfileImage.js +5 -3
- package/lib/components/Carousel/Carousel.d.ts +46 -2
- package/lib/components/Carousel/Carousel.js +35 -20
- package/lib/components/Carousel/CarouselItem.d.ts +19 -2
- package/lib/components/Carousel/CarouselItem.js +0 -1
- package/lib/components/Coachmark/utils/enums.d.ts +36 -22
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.d.ts +26 -2
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +1 -3
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.d.ts +28 -2
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +0 -1
- package/lib/components/ConditionBuilder/assets/sampleInput.d.ts +5 -5
- package/lib/components/CreateFullPage/CreateFullPage.d.ts +121 -4
- package/lib/components/CreateFullPage/CreateFullPage.js +12 -8
- package/lib/components/CreateTearsheet/CreateTearsheet.js +2 -0
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +4 -3
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +2 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +11 -7
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -2
- package/lib/components/EditFullPage/EditFullPage.d.ts +19 -2
- package/lib/components/EditFullPage/EditFullPage.js +3 -3
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -3
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -2
- package/lib/components/FullPageError/FullPageError.d.ts +2 -1
- package/lib/components/FullPageError/FullPageError.js +24 -49
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.d.ts +40 -2
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +1 -1
- package/lib/components/InlineTip/InlineTipLink.d.ts +19 -2
- package/lib/components/InterstitialScreenView/InterstitialScreenView.d.ts +23 -2
- package/lib/components/InterstitialScreenView/InterstitialScreenView.js +0 -1
- package/lib/components/InterstitialScreenViewModule/InterstitialScreenViewModule.d.ts +23 -2
- package/lib/components/NonLinearReading/NonLinearReading.d.ts +28 -2
- package/lib/components/NonLinearReading/NonLinearReading.js +2 -7
- package/lib/components/SearchBar/SearchBar.d.ts +51 -3
- package/lib/components/SearchBar/SearchBar.js +5 -6
- package/lib/components/SidePanel/SidePanel.js +10 -5
- package/lib/components/TruncatedList/TruncatedList.d.ts +47 -2
- package/lib/components/TruncatedList/TruncatedList.js +5 -4
- package/lib/components/UserProfileImage/UserProfileImage.d.ts +66 -2
- package/lib/components/UserProfileImage/UserProfileImage.js +5 -3
- package/package.json +7 -7
- package/scss/components/Datagrid/styles/_useSortableColumns.scss +2 -0
- package/scss/components/FullPageError/_full-page-error.scss +10 -10
- package/scss/components/UserAvatar/_user-avatar.scss +6 -3
- package/telemetry.yml +3 -0
@@ -20,12 +20,6 @@ var _excluded = ["children", "className", "definition", "theme"];
|
|
20
20
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
21
21
|
var blockClass = "".concat(pkg.prefix, "--non-linear-reading");
|
22
22
|
var componentName = 'NonLinearReading';
|
23
|
-
|
24
|
-
// Default values for props
|
25
|
-
var defaults = {
|
26
|
-
theme: 'light'
|
27
|
-
};
|
28
|
-
|
29
23
|
/**
|
30
24
|
* Use non-linear reading when space is limited to share a
|
31
25
|
* brief, at-a-glance, summary of a concept that may require
|
@@ -36,7 +30,7 @@ var NonLinearReading = /*#__PURE__*/React__default.forwardRef(function (_ref, re
|
|
36
30
|
className = _ref.className,
|
37
31
|
definition = _ref.definition,
|
38
32
|
_ref$theme = _ref.theme,
|
39
|
-
theme = _ref$theme === void 0 ?
|
33
|
+
theme = _ref$theme === void 0 ? 'light' : _ref$theme,
|
40
34
|
rest = _objectWithoutProperties(_ref, _excluded);
|
41
35
|
var _useState = useState(false),
|
42
36
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -73,6 +67,7 @@ NonLinearReading.propTypes = {
|
|
73
67
|
/**
|
74
68
|
* The keyword of the component appears as a pill.
|
75
69
|
*/
|
70
|
+
|
76
71
|
children: PropTypes.node.isRequired,
|
77
72
|
/**
|
78
73
|
* Provide an optional class to be applied to the containing node.
|
@@ -1,5 +1,53 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* Copyright IBM Corp. 2024, 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.
|
3
6
|
*/
|
4
|
-
|
5
|
-
|
7
|
+
import React, { PropsWithChildren } from 'react';
|
8
|
+
type Scopes = string[] | object[];
|
9
|
+
interface SearchBarProps extends PropsWithChildren {
|
10
|
+
/** @type {string} Optional additional class name. */
|
11
|
+
className?: string;
|
12
|
+
/** @type {string} The label text for the search text input. */
|
13
|
+
clearButtonLabelText: string;
|
14
|
+
/**
|
15
|
+
* Whether or not the scopes MultiSelect label is visually hidden.
|
16
|
+
*/
|
17
|
+
hideScopesLabel?: boolean;
|
18
|
+
/** @type {string} The label text for the search text input. */
|
19
|
+
labelText?: string;
|
20
|
+
/** @type {Function} Function handler for when the user changes their query search. */
|
21
|
+
onChange?: (event: any) => void;
|
22
|
+
/** @type {Function} Function handler for when the user submits a search. */
|
23
|
+
onSubmit?: (event: any) => void;
|
24
|
+
/** @type {string} Placeholder text to be displayed in the search input. */
|
25
|
+
placeHolderText: string;
|
26
|
+
/** @type {Function} Function to get the text for each scope to display in dropdown. */
|
27
|
+
scopeToString?: () => void;
|
28
|
+
/** @type {Array<any>} Array of allowed search scopes. */
|
29
|
+
scopes?: Scopes;
|
30
|
+
/** @type {string} The name text for the search scope type. */
|
31
|
+
scopesTypeLabel?: typeof conditionalScopePropValidator;
|
32
|
+
/** @type {Array<any> Array of initially selected search scopes. */
|
33
|
+
selectedScopes?: Scopes;
|
34
|
+
/**
|
35
|
+
* Optional custom sorting algorithm for an array of scope items.
|
36
|
+
* By default, scope items are sorted in ascending alphabetical order,
|
37
|
+
* with "selected" items moved to the start of the scope items array.
|
38
|
+
*/
|
39
|
+
sortItems?: () => void;
|
40
|
+
/** @type {string} The label text for the search submit button. */
|
41
|
+
submitLabel: string;
|
42
|
+
/**
|
43
|
+
* Provide accessible label text for the scopes MultiSelect.
|
44
|
+
*/
|
45
|
+
titleText?: string;
|
46
|
+
/** @type {func} Callback function for translating MultiSelect's child ListBoxMenuIcon SVG title. */
|
47
|
+
translateWithId?: () => void;
|
48
|
+
/** @type {string} Search query value. */
|
49
|
+
value?: string;
|
50
|
+
}
|
51
|
+
export declare let SearchBar: React.ForwardRefExoticComponent<SearchBarProps & React.RefAttributes<HTMLFormElement>>;
|
52
|
+
declare const conditionalScopePropValidator: (props: any, propName: any, componentName: any, ...rest: any[]) => Error | null;
|
53
|
+
export {};
|
@@ -29,10 +29,6 @@ var defaults = {
|
|
29
29
|
selectedScopes: [],
|
30
30
|
hideScopesLabel: true
|
31
31
|
};
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Search bar with input field and search button
|
35
|
-
*/
|
36
32
|
var SearchBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
37
33
|
var className = _ref.className,
|
38
34
|
clearButtonLabelText = _ref.clearButtonLabelText,
|
@@ -45,11 +41,11 @@ var SearchBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
45
41
|
onSubmit = _ref$onSubmit === void 0 ? defaults.onSubmit : _ref$onSubmit,
|
46
42
|
placeHolderText = _ref.placeHolderText,
|
47
43
|
_ref$scopes = _ref.scopes,
|
48
|
-
scopes = _ref$scopes === void 0 ?
|
44
|
+
scopes = _ref$scopes === void 0 ? [] : _ref$scopes,
|
49
45
|
scopesTypeLabel = _ref.scopesTypeLabel,
|
50
46
|
scopeToString = _ref.scopeToString,
|
51
47
|
_ref$selectedScopes = _ref.selectedScopes,
|
52
|
-
selectedScopes = _ref$selectedScopes === void 0 ?
|
48
|
+
selectedScopes = _ref$selectedScopes === void 0 ? [] : _ref$selectedScopes,
|
53
49
|
sortItems = _ref.sortItems,
|
54
50
|
submitLabel = _ref.submitLabel,
|
55
51
|
translateWithId = _ref.translateWithId,
|
@@ -162,6 +158,7 @@ var conditionalScopePropValidator = function conditionalScopePropValidator(props
|
|
162
158
|
if (props.scopes && props.scopes.length > 0 && !props[propName]) {
|
163
159
|
return new Error("Required `".concat(propName, "` when `scopes` prop type is supplied to `").concat(componentName, "`. Validation failed."));
|
164
160
|
}
|
161
|
+
/**@ts-ignore */
|
165
162
|
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
166
163
|
rest[_key - 3] = arguments[_key];
|
167
164
|
}
|
@@ -191,11 +188,13 @@ SearchBar.propTypes = {
|
|
191
188
|
/** @type {Function} Function to get the text for each scope to display in dropdown. */
|
192
189
|
scopeToString: PropTypes.func,
|
193
190
|
/** @type {Array<any>} Array of allowed search scopes. */
|
191
|
+
/**@ts-ignore */
|
194
192
|
scopes: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])),
|
195
193
|
/** @type {string} The name text for the search scope type. */
|
196
194
|
// eslint-disable-next-line react/require-default-props
|
197
195
|
scopesTypeLabel: conditionalScopePropValidator,
|
198
196
|
/** @type {Array<any> Array of initially selected search scopes. */
|
197
|
+
/**@ts-ignore */
|
199
198
|
selectedScopes: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])),
|
200
199
|
/**
|
201
200
|
* Optional custom sorting algorithm for an array of scope items.
|
@@ -24,7 +24,7 @@ import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
|
24
24
|
import { useFocus } from '../../global/js/hooks/useFocus.js';
|
25
25
|
|
26
26
|
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"],
|
27
|
-
_excluded2 = ["label", "kind", "icon", "tooltipPosition", "tooltipAlignment", "leading", "disabled", "className", "onClick"];
|
27
|
+
_excluded2 = ["label", "kind", "hasIconOnly", "icon", "renderIcon", "tooltipPosition", "tooltipAlignment", "leading", "disabled", "className", "onClick"];
|
28
28
|
var blockClass = "".concat(pkg.prefix, "--side-panel");
|
29
29
|
var componentName = 'SidePanel';
|
30
30
|
// `any` is a work around until ActionSet is migrated to TS
|
@@ -387,7 +387,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
387
387
|
}, actionToolbarButtons.map(function (_ref4) {
|
388
388
|
var label = _ref4.label,
|
389
389
|
kind = _ref4.kind,
|
390
|
+
_ref4$hasIconOnly = _ref4.hasIconOnly,
|
391
|
+
hasIconOnly = _ref4$hasIconOnly === void 0 ? false : _ref4$hasIconOnly,
|
390
392
|
icon = _ref4.icon,
|
393
|
+
renderIcon = _ref4.renderIcon,
|
391
394
|
tooltipPosition = _ref4.tooltipPosition,
|
392
395
|
tooltipAlignment = _ref4.tooltipAlignment,
|
393
396
|
leading = _ref4.leading,
|
@@ -399,11 +402,13 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
399
402
|
key: label,
|
400
403
|
kind: kind || 'ghost',
|
401
404
|
size: "sm",
|
402
|
-
renderIcon: icon,
|
403
|
-
iconDescription: label
|
405
|
+
renderIcon: renderIcon || icon,
|
406
|
+
iconDescription: label
|
407
|
+
}, hasIconOnly && {
|
404
408
|
tooltipPosition: tooltipPosition || 'bottom',
|
405
|
-
tooltipAlignment: tooltipAlignment || 'start'
|
406
|
-
|
409
|
+
tooltipAlignment: tooltipAlignment || 'start'
|
410
|
+
}, {
|
411
|
+
hasIconOnly: hasIconOnly,
|
407
412
|
disabled: disabled,
|
408
413
|
className: cx(["".concat(blockClass, "__action-toolbar-button"), className, _defineProperty({}, "".concat(blockClass, "__action-toolbar-leading-button"), leading)]),
|
409
414
|
onClick: onClick
|
@@ -1,7 +1,52 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2024, 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
|
+
import React, { PropsWithChildren, ReactNode } from 'react';
|
8
|
+
interface TruncatedListProps extends PropsWithChildren {
|
9
|
+
as?: React.ElementType | string;
|
10
|
+
/**
|
11
|
+
* Optional class name for expand/collapse button.
|
12
|
+
*/
|
13
|
+
buttonClassName?: string;
|
14
|
+
/**
|
15
|
+
* The contents of the TruncatedList.
|
16
|
+
*/
|
17
|
+
children: ReactNode;
|
18
|
+
/**
|
19
|
+
* Provide an optional class to be applied to the containing node.
|
20
|
+
*/
|
21
|
+
className?: string;
|
22
|
+
/**
|
23
|
+
* Number of items to render and display when the list is truncated and collapsed.
|
24
|
+
* Scrolling is not enabled when collapsed. The smallest number is 1.
|
25
|
+
*/
|
26
|
+
collapsedItemsLimit?: number;
|
27
|
+
/**
|
28
|
+
* Maximum number of items to show when the list is expanded. All
|
29
|
+
* items are rendered when the list is expanded. Scrolling is enabled
|
30
|
+
* if there are more items to display than this number.
|
31
|
+
*/
|
32
|
+
expandedItemsLimit?: number;
|
33
|
+
/**
|
34
|
+
* Optional callback reports the collapsed state of the list.
|
35
|
+
*/
|
36
|
+
onClick?: (value: any) => void;
|
37
|
+
/**
|
38
|
+
* Text label for when the list is expanded.
|
39
|
+
*/
|
40
|
+
viewLessLabel?: string;
|
41
|
+
/**
|
42
|
+
* Callback function for building the label when the list is collapsed.
|
43
|
+
*/
|
44
|
+
viewMoreLabel?: (value: any) => void;
|
45
|
+
}
|
1
46
|
/**
|
2
47
|
* The `TruncatedList` allows consumers to control how many items are
|
3
48
|
* revealed to the user while giving the user the ability to expand
|
4
49
|
* and see the entire list.
|
5
50
|
*/
|
6
|
-
export let TruncatedList: React.ForwardRefExoticComponent<React.RefAttributes<
|
7
|
-
|
51
|
+
export declare let TruncatedList: React.ForwardRefExoticComponent<TruncatedListProps & React.RefAttributes<HTMLDivElement>>;
|
52
|
+
export {};
|
@@ -28,7 +28,6 @@ var defaults = {
|
|
28
28
|
return "View more (".concat(value, ")");
|
29
29
|
}
|
30
30
|
};
|
31
|
-
|
32
31
|
/**
|
33
32
|
* The `TruncatedList` allows consumers to control how many items are
|
34
33
|
* revealed to the user while giving the user the ability to expand
|
@@ -84,13 +83,15 @@ var TruncatedList = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
84
83
|
// list is both collapsed and expanded.
|
85
84
|
useEffect(function () {
|
86
85
|
if (listRef && childrenArray.length > 0) {
|
86
|
+
var _listRef$current;
|
87
87
|
var numItemsToShow = isCollapsed ? minItems : maxItems;
|
88
|
-
var items = listRef.current.childNodes;
|
88
|
+
var items = (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.childNodes;
|
89
89
|
var _listHeight = 0;
|
90
90
|
for (var index = 0; index < numItemsToShow; index++) {
|
91
|
-
if (items[index]) {
|
91
|
+
if (items && items[index]) {
|
92
92
|
var _window;
|
93
|
-
var
|
93
|
+
var itemElement = items[index];
|
94
|
+
var height = ((_window = window) === null || _window === void 0 || (_window = _window.getComputedStyle(itemElement)) === null || _window === void 0 ? void 0 : _window.height) || '16';
|
94
95
|
_listHeight += parseInt(height);
|
95
96
|
}
|
96
97
|
}
|
@@ -1,5 +1,69 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* Copyright IBM Corp. 2021, 2021
|
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.
|
3
6
|
*/
|
4
|
-
|
7
|
+
/// <reference path="../../../src/custom-typings/index.d.ts" />
|
5
8
|
import React from 'react';
|
9
|
+
import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
|
10
|
+
import '../../global/js/utils/props-helper';
|
11
|
+
import { IconButton } from '@carbon/react';
|
12
|
+
type imageProps = {
|
13
|
+
/**
|
14
|
+
* When passing the image prop, supply a full path to the image to be displayed.
|
15
|
+
*/
|
16
|
+
image: string;
|
17
|
+
/**
|
18
|
+
* When passing the image prop use the imageDescription prop to describe the image for screen reader.
|
19
|
+
*/
|
20
|
+
imageDescription: string;
|
21
|
+
} | {
|
22
|
+
image?: never;
|
23
|
+
imageDescription?: never;
|
24
|
+
};
|
25
|
+
type UserProfileImageBaseProps = {
|
26
|
+
/**
|
27
|
+
* The background color passed should match one of the background colors in the library documentation:
|
28
|
+
* https://pages.github.ibm.com/cdai-design/pal/patterns/user-profile-images/
|
29
|
+
*/
|
30
|
+
backgroundColor?: string;
|
31
|
+
/**
|
32
|
+
* Provide an optional class to be applied to the containing node.
|
33
|
+
*/
|
34
|
+
className?: string;
|
35
|
+
/**
|
36
|
+
* Provide a custom icon to use if you need to use an icon other than the included ones
|
37
|
+
*/
|
38
|
+
icon?: () => CarbonIconType | null;
|
39
|
+
/**
|
40
|
+
* When passing the initials prop, either send the initials to be used or the user's display name. The first two capital letters of the display name will be used as the initials.
|
41
|
+
*/
|
42
|
+
initials?: string;
|
43
|
+
/**
|
44
|
+
* When passing the kind prop, use either "user" or "group". The values match up to the Carbon Library icons.
|
45
|
+
*/
|
46
|
+
kind?: 'user' | 'group';
|
47
|
+
/**
|
48
|
+
* Set the size of the avatar circle
|
49
|
+
*/
|
50
|
+
size: 'xl' | 'lg' | 'md';
|
51
|
+
/**
|
52
|
+
* Set theme in which the component will be rendered
|
53
|
+
*/
|
54
|
+
theme: 'light' | 'dark';
|
55
|
+
/**
|
56
|
+
* Specify how the trigger should align with the tooltip
|
57
|
+
*/
|
58
|
+
tooltipAlignment?: React.ComponentProps<typeof IconButton>['align'];
|
59
|
+
/**
|
60
|
+
* Pass in the display name to have it shown on hover
|
61
|
+
*/
|
62
|
+
tooltipText?: string;
|
63
|
+
};
|
64
|
+
type UserProfileImageProps = UserProfileImageBaseProps & imageProps;
|
65
|
+
/**
|
66
|
+
* The user profile avatar allows for an image of the user to be displayed by passing in the image prop. By default the component will display a user icon on a blue background.
|
67
|
+
*/
|
68
|
+
export declare let UserProfileImage: React.ForwardRefExoticComponent<UserProfileImageProps & React.RefAttributes<HTMLDivElement>>;
|
69
|
+
export {};
|
@@ -17,7 +17,6 @@ import { usePrefix, Tooltip } from '@carbon/react';
|
|
17
17
|
import { TooltipTrigger } from '../TooltipTrigger/TooltipTrigger.js';
|
18
18
|
|
19
19
|
var _excluded = ["backgroundColor", "className", "kind", "icon", "initials", "image", "imageDescription", "size", "theme", "tooltipText", "tooltipAlignment"];
|
20
|
-
|
21
20
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
22
21
|
var blockClass = "".concat(pkg.prefix, "--user-profile-image");
|
23
22
|
var componentName = 'UserProfileImage';
|
@@ -84,12 +83,13 @@ var UserProfileImage = /*#__PURE__*/React__default.forwardRef(function (_ref, re
|
|
84
83
|
}
|
85
84
|
};
|
86
85
|
var formatInitials = function formatInitials() {
|
87
|
-
|
86
|
+
var _match;
|
87
|
+
if (initials && initials.length === 2) {
|
88
88
|
return initials;
|
89
89
|
}
|
90
90
|
// RegEx takes in the display name and returns the first and last initials. Thomas Watson and Thomas J. Watson
|
91
91
|
// both return JW.
|
92
|
-
return initials.match(/(^\S\S?|\b\S)?/g).join('').match(/(^\S|\S$)?/g).join('').toUpperCase();
|
92
|
+
return ((_match = (initials || '').match(/(^\S\S?|\b\S)?/g)) === null || _match === void 0 || (_match = _match.join('').match(/(^\S|\S$)?/g)) === null || _match === void 0 ? void 0 : _match.join('').toUpperCase()) || '';
|
93
93
|
};
|
94
94
|
var getFillItem = function getFillItem() {
|
95
95
|
if (image) {
|
@@ -149,10 +149,12 @@ UserProfileImage.propTypes = {
|
|
149
149
|
/**
|
150
150
|
* When passing the image prop, supply a full path to the image to be displayed.
|
151
151
|
*/
|
152
|
+
/**@ts-ignore */
|
152
153
|
image: PropTypes.string,
|
153
154
|
/**
|
154
155
|
* When passing the image prop use the imageDescription prop to describe the image for screen reader.
|
155
156
|
*/
|
157
|
+
/**@ts-ignore */
|
156
158
|
imageDescription: PropTypes.string.isRequired.if(function (_ref2) {
|
157
159
|
var image = _ref2.image;
|
158
160
|
return !!image;
|
@@ -1,3 +1,47 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { ReactNode } from 'react';
|
8
|
+
interface CarouselProps {
|
9
|
+
/**
|
10
|
+
* Provide the contents of the Carousel.
|
11
|
+
*/
|
12
|
+
children: ReactNode;
|
13
|
+
/**
|
14
|
+
* Provide an optional class to be applied to the containing node.
|
15
|
+
*/
|
16
|
+
className?: string;
|
17
|
+
/**
|
18
|
+
* Disables the ability of the Carousel to scroll
|
19
|
+
* use a keyboard's left and right arrow keys.
|
20
|
+
*/
|
21
|
+
disableArrowScroll?: boolean;
|
22
|
+
/**
|
23
|
+
* Enables the edges of the component to have faded styling.
|
24
|
+
*
|
25
|
+
* Pass a single string (`$color`) to specify the same color for left and right.
|
26
|
+
*
|
27
|
+
* Or pass an object (`{ left: $color1, right: $color2 }`) to specify different colors.
|
28
|
+
*/
|
29
|
+
fadedEdgeColor?: string | {
|
30
|
+
left: string;
|
31
|
+
right: string;
|
32
|
+
};
|
33
|
+
/**
|
34
|
+
* An optional callback function that returns `true`
|
35
|
+
* when the carousel has enough content to be scrollable,
|
36
|
+
* and `false` when there is not enough content.
|
37
|
+
*/
|
38
|
+
onChangeIsScrollable?: (isScrollable: boolean) => void;
|
39
|
+
/**
|
40
|
+
* An optional callback function that returns the scroll position as
|
41
|
+
* a value between 0 and 1.
|
42
|
+
*/
|
43
|
+
onScroll?: (scrollPercent: number) => void;
|
44
|
+
}
|
1
45
|
/**
|
2
46
|
* The Carousel acts as a scaffold for other Novice to Pro content.
|
3
47
|
*
|
@@ -14,5 +58,5 @@
|
|
14
58
|
* 2. From the right-aligned position, when scrolling left,
|
15
59
|
* the left-most item should again be left-aligned.
|
16
60
|
*/
|
17
|
-
|
18
|
-
|
61
|
+
declare const Carousel: React.ForwardRefExoticComponent<CarouselProps & React.RefAttributes<HTMLDivElement>>;
|
62
|
+
export { Carousel };
|
@@ -23,7 +23,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
23
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
24
24
|
|
25
25
|
var _excluded = ["children", "className", "disableArrowScroll", "fadedEdgeColor", "onChangeIsScrollable", "onScroll"];
|
26
|
-
|
27
26
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
28
27
|
var blockClass = "".concat(settings.pkg.prefix, "--carousel");
|
29
28
|
var componentName = 'Carousel';
|
@@ -62,29 +61,31 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
62
61
|
_ref$onScroll = _ref.onScroll,
|
63
62
|
onScroll = _ref$onScroll === void 0 ? defaults.onScroll : _ref$onScroll,
|
64
63
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
65
|
-
var carouselRef = React.useRef();
|
66
|
-
var scrollRef = React.useRef();
|
64
|
+
var carouselRef = React.useRef(null);
|
65
|
+
var scrollRef = React.useRef(null);
|
67
66
|
// Array of refs used to reference this component's children DOM elements
|
68
67
|
var childElementsRef = React.useRef(Array(React__default["default"].Children.count(children)).fill(React.useRef(null)));
|
69
|
-
var leftFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.left
|
70
|
-
var rightFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.right
|
68
|
+
var leftFadedEdgeColor = _rollupPluginBabelHelpers["typeof"](fadedEdgeColor) === 'object' ? fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.left : fadedEdgeColor;
|
69
|
+
var rightFadedEdgeColor = _rollupPluginBabelHelpers["typeof"](fadedEdgeColor) === 'object' ? fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.right : fadedEdgeColor;
|
71
70
|
|
72
71
|
// Trigger callbacks to report state of the carousel
|
73
72
|
var handleOnScroll = React.useCallback(function () {
|
73
|
+
var _scrollRef$current, _scrollRef$current2, _scrollRef$current3;
|
74
|
+
if (!scrollRef.current) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
|
74
78
|
// viewport's width
|
75
|
-
var clientWidth = scrollRef.current.clientWidth;
|
79
|
+
var clientWidth = (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.clientWidth;
|
76
80
|
// scroll position
|
77
|
-
var scrollLeft = parseInt(scrollRef.current.scrollLeft, 10);
|
81
|
+
var scrollLeft = parseInt("".concat((_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 ? void 0 : _scrollRef$current2.scrollLeft), 10);
|
78
82
|
// scrollable width
|
79
|
-
var scrollWidth = scrollRef.current.scrollWidth;
|
83
|
+
var scrollWidth = (_scrollRef$current3 = scrollRef.current) === null || _scrollRef$current3 === void 0 ? void 0 : _scrollRef$current3.scrollWidth;
|
80
84
|
|
81
85
|
// The maximum scrollLeft achievable is the scrollable width - the viewport width.
|
82
86
|
var scrollLeftMax = scrollWidth - clientWidth;
|
83
87
|
// if isNaN(scrollLeft / scrollLeftMax), then set to zero
|
84
88
|
var scrollPercent = parseFloat((scrollLeft / scrollLeftMax).toFixed(2)) || 0;
|
85
|
-
if (!scrollRef.current) {
|
86
|
-
return;
|
87
|
-
}
|
88
89
|
|
89
90
|
// Callback 1: Does the carousel have enough content to enable scrolling?
|
90
91
|
onChangeIsScrollable(scrollWidth > clientWidth);
|
@@ -104,7 +105,8 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
104
105
|
|
105
106
|
// Get all elements that are visible in the container.
|
106
107
|
var getElementsInView = React.useCallback(function () {
|
107
|
-
var
|
108
|
+
var _scrollRef$current4;
|
109
|
+
var containerRect = scrollRef === null || scrollRef === void 0 || (_scrollRef$current4 = scrollRef.current) === null || _scrollRef$current4 === void 0 ? void 0 : _scrollRef$current4.getBoundingClientRect();
|
108
110
|
var inViewElements = childElementsRef.current.filter(function (el) {
|
109
111
|
return getElementInView(containerRect, el.getBoundingClientRect());
|
110
112
|
});
|
@@ -113,8 +115,9 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
113
115
|
|
114
116
|
// Return container's and children's rect data
|
115
117
|
var getContainerAndChildRectData = React.useCallback(function () {
|
118
|
+
var _scrollRef$current5;
|
116
119
|
// Get the rect of the container
|
117
|
-
var containerRect = scrollRef.current.getBoundingClientRect();
|
120
|
+
var containerRect = scrollRef === null || scrollRef === void 0 || (_scrollRef$current5 = scrollRef.current) === null || _scrollRef$current5 === void 0 ? void 0 : _scrollRef$current5.getBoundingClientRect();
|
118
121
|
// Get all child elements that are in view of the container, and return their bounding rects.
|
119
122
|
var elementRectsInView = getElementsInView().map(function (el) {
|
120
123
|
return el.getBoundingClientRect();
|
@@ -132,27 +135,37 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
132
135
|
};
|
133
136
|
}, [getElementsInView]);
|
134
137
|
var handleScrollNext = React.useCallback(function () {
|
138
|
+
if (!scrollRef.current) {
|
139
|
+
return;
|
140
|
+
}
|
135
141
|
var _getContainerAndChild = getContainerAndChildRectData(),
|
136
142
|
containerRect = _getContainerAndChild.containerRect,
|
137
143
|
visibleWidth = _getContainerAndChild.visibleWidth;
|
138
144
|
// Set the scrollValue to the visibleWidth, but if the visibleWidth value is 0, set it to the container's width
|
139
|
-
var scrollValue = visibleWidth > 0 ? visibleWidth : containerRect.width;
|
145
|
+
var scrollValue = visibleWidth > 0 ? visibleWidth : containerRect === null || containerRect === void 0 ? void 0 : containerRect.width;
|
140
146
|
// Increment the scrollLeft of the container
|
141
147
|
scrollRef.current.scrollLeft += scrollValue;
|
142
148
|
}, [getContainerAndChildRectData]);
|
143
149
|
var handleScrollPrev = React.useCallback(function () {
|
150
|
+
var _containerRect$width, _containerRect$left;
|
151
|
+
if (!scrollRef.current) {
|
152
|
+
return;
|
153
|
+
}
|
144
154
|
var _getContainerAndChild2 = getContainerAndChildRectData(),
|
145
155
|
containerRect = _getContainerAndChild2.containerRect,
|
146
156
|
elementRectsInView = _getContainerAndChild2.elementRectsInView,
|
147
157
|
visibleWidth = _getContainerAndChild2.visibleWidth;
|
148
158
|
// Set the scrollValue to the visibleWidth minus the first child's left value,
|
149
159
|
// but if the visibleWidth value is 0, set it to the container's width plus the container's left value
|
150
|
-
var scrollValue = visibleWidth > 0 ? visibleWidth - elementRectsInView[0].left : containerRect.width + containerRect.left;
|
160
|
+
var scrollValue = visibleWidth > 0 ? visibleWidth - elementRectsInView[0].left : ((_containerRect$width = containerRect === null || containerRect === void 0 ? void 0 : containerRect.width) !== null && _containerRect$width !== void 0 ? _containerRect$width : 0) + ((_containerRect$left = containerRect === null || containerRect === void 0 ? void 0 : containerRect.left) !== null && _containerRect$left !== void 0 ? _containerRect$left : 0);
|
151
161
|
|
152
162
|
// Decrement the scrollLeft of the container
|
153
163
|
scrollRef.current.scrollLeft -= scrollValue;
|
154
164
|
}, [getContainerAndChildRectData]);
|
155
165
|
var handleScrollReset = React.useCallback(function () {
|
166
|
+
if (!scrollRef.current) {
|
167
|
+
return;
|
168
|
+
}
|
156
169
|
// This doesn't trigger "scrollend"...
|
157
170
|
scrollRef.current.scrollLeft = 0;
|
158
171
|
// ...so trigger a callback manually.
|
@@ -179,6 +192,9 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
179
192
|
// On window.resize, reset carousel to zero.
|
180
193
|
React.useEffect(function () {
|
181
194
|
var handleWindowResize = function handleWindowResize() {
|
195
|
+
if (!scrollRef.current) {
|
196
|
+
return;
|
197
|
+
}
|
182
198
|
scrollRef.current.scrollLeft = 0;
|
183
199
|
handleOnScroll();
|
184
200
|
};
|
@@ -194,9 +210,9 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
194
210
|
handleOnScroll();
|
195
211
|
};
|
196
212
|
var scrollDiv = scrollRef.current;
|
197
|
-
scrollDiv.addEventListener('scrollend', handleScrollend);
|
213
|
+
scrollDiv === null || scrollDiv === void 0 || scrollDiv.addEventListener('scrollend', handleScrollend);
|
198
214
|
return function () {
|
199
|
-
return scrollDiv.removeEventListener('scrollend', handleScrollend);
|
215
|
+
return scrollDiv === null || scrollDiv === void 0 ? void 0 : scrollDiv.removeEventListener('scrollend', handleScrollend);
|
200
216
|
};
|
201
217
|
}, [handleOnScroll]);
|
202
218
|
|
@@ -216,9 +232,7 @@ var Carousel = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
216
232
|
passive: false
|
217
233
|
});
|
218
234
|
return function () {
|
219
|
-
scrollDiv.removeEventListener('wheel', handleWheel
|
220
|
-
passive: false
|
221
|
-
});
|
235
|
+
scrollDiv.removeEventListener('wheel', handleWheel);
|
222
236
|
};
|
223
237
|
}
|
224
238
|
}, []);
|
@@ -314,6 +328,7 @@ Carousel.propTypes = {
|
|
314
328
|
*
|
315
329
|
* Or pass an object (`{ left: $color1, right: $color2 }`) to specify different colors.
|
316
330
|
*/
|
331
|
+
/**@ts-ignore*/
|
317
332
|
fadedEdgeColor: index["default"].oneOfType([index["default"].string, index["default"].shape({
|
318
333
|
left: index["default"].string,
|
319
334
|
right: index["default"].string
|
@@ -1,5 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import React, { ReactNode } from 'react';
|
8
|
+
interface CarouselItemProps {
|
9
|
+
/**
|
10
|
+
* Provide the contents of the CarouselItem.
|
11
|
+
*/
|
12
|
+
children: ReactNode;
|
13
|
+
/**
|
14
|
+
* Provide an optional class to be applied to the containing node.
|
15
|
+
*/
|
16
|
+
className?: string;
|
17
|
+
}
|
1
18
|
/**
|
2
19
|
* TODO: A description of the component.
|
3
20
|
*/
|
4
|
-
|
5
|
-
|
21
|
+
declare const CarouselItem: React.ForwardRefExoticComponent<CarouselItemProps & React.RefAttributes<HTMLDivElement>>;
|
22
|
+
export { CarouselItem };
|
@@ -22,7 +22,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
22
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
23
23
|
|
24
24
|
var _excluded = ["children", "className"];
|
25
|
-
|
26
25
|
// Carbon and package components we use.
|
27
26
|
/* TODO: @import(s) of carbon components and other package components. */
|
28
27
|
|