@carbon/ibm-products 2.34.0 → 2.36.0-alpha.27
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +32448 -32421
- 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 +105 -91
- 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 +765 -24496
- 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 +2543 -18127
- 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.d.ts +38 -2
- package/es/components/ActionSet/ActionSet.js +3 -5
- 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/CoachmarkFixed/CoachmarkFixed.js +1 -1
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.d.ts +28 -2
- package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +0 -1
- package/es/components/ConditionBuilder/ConditionBuilder.d.ts +5 -0
- package/es/components/ConditionBuilder/ConditionBuilder.js +125 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +10 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +92 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataTreeContext.d.ts +38 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataTreeContext.js +88 -0
- package/es/components/ConditionBuilder/assets/sampleInput.d.ts +58 -0
- package/es/components/ConditionBuilder/index.d.ts +1 -0
- package/es/components/CreateFullPage/CreateFullPage.d.ts +121 -4
- package/es/components/CreateFullPage/CreateFullPage.js +14 -26
- package/es/components/CreateFullPage/CreateFullPageStep.js +22 -7
- package/es/components/CreateTearsheet/CreateTearsheet.js +2 -0
- package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.d.ts +82 -2
- 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/Datagrid/Datagrid/addons/stateReducer.js +2 -1
- package/es/components/Datagrid/useEditableCell.js +15 -0
- package/es/components/DelimitedList/DelimitedList.d.ts +27 -2
- package/es/components/DelimitedList/DelimitedList.js +0 -1
- package/es/components/EditFullPage/EditFullPage.d.ts +19 -2
- package/es/components/EditFullPage/EditFullPage.js +3 -3
- package/es/components/EditInPlace/EditInPlace.d.ts +97 -5
- package/es/components/EditInPlace/EditInPlace.js +10 -6
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -3
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -2
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -3
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.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/ExportModal/ExportModal.d.ts +110 -2
- package/es/components/ExportModal/ExportModal.js +10 -4
- package/es/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.js +1 -1
- package/es/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.js +2 -2
- package/es/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.d.ts +5 -0
- package/es/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.js +5 -9
- package/es/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.js +1 -1
- package/es/components/FilterPanel/FilterPanelSearch/FilterPanelSearch.d.ts +5 -0
- package/es/components/FilterPanel/FilterPanelSearch/FilterPanelSearch.js +92 -0
- package/es/components/FilterPanel/index.d.ts +1 -0
- package/es/components/FullPageError/FullPageError.d.ts +2 -1
- package/es/components/FullPageError/FullPageError.js +24 -49
- package/es/components/HTTPErrors/HTTPError403/HTTPError403.d.ts +40 -2
- package/es/components/HTTPErrors/HTTPError403/HTTPError403.js +1 -1
- package/es/components/HTTPErrors/HTTPError404/HTTPError404.d.ts +40 -2
- package/es/components/HTTPErrors/HTTPError404/HTTPError404.js +1 -1
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.d.ts +40 -2
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +1 -1
- package/es/components/ImportModal/ImportModal.d.ts +136 -2
- package/es/components/ImportModal/ImportModal.js +3 -2
- package/es/components/InlineTip/InlineTip.d.ts +90 -2
- package/es/components/InlineTip/InlineTip.js +3 -2
- 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/Nav/Nav.js +1 -1
- package/es/components/Nav/NavList.js +7 -7
- package/es/components/NonLinearReading/NonLinearReading.d.ts +28 -2
- package/es/components/NonLinearReading/NonLinearReading.js +2 -7
- package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
- package/es/components/PageHeader/PageHeader.js +3 -3
- package/es/components/PageHeader/PageHeaderUtils.d.ts +1 -1
- package/es/components/PageHeader/PageHeaderUtils.js +4 -3
- package/es/components/SearchBar/SearchBar.d.ts +51 -3
- package/es/components/SearchBar/SearchBar.js +5 -6
- package/es/components/SidePanel/SidePanel.js +62 -41
- package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.d.ts +23 -2
- package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +6 -5
- package/es/components/TagOverflow/TagOverflow.d.ts +5 -0
- package/es/components/TagOverflow/TagOverflow.js +209 -0
- package/es/components/TagOverflow/constants.d.ts +14 -0
- package/es/components/TagOverflow/constants.js +30 -0
- package/es/components/TagOverflow/index.d.ts +1 -0
- package/es/components/Tearsheet/TearsheetNarrow.d.ts +105 -6
- package/es/components/Tearsheet/TearsheetNarrow.js +6 -1
- package/es/components/Toolbar/Toolbar.d.ts +23 -5
- package/es/components/Toolbar/Toolbar.js +30 -26
- package/es/components/TruncatedList/TruncatedList.d.ts +47 -2
- package/es/components/TruncatedList/TruncatedList.js +5 -4
- package/es/components/UserAvatar/UserAvatar.js +4 -2
- package/es/components/index.d.ts +4 -2
- package/es/global/js/package-settings.d.ts +3 -0
- package/es/global/js/package-settings.js +3 -0
- package/es/index.js +4 -0
- package/es/settings.d.ts +3 -0
- package/lib/components/ActionSet/ActionSet.d.ts +38 -2
- package/lib/components/ActionSet/ActionSet.js +3 -5
- 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/CoachmarkFixed/CoachmarkFixed.js +1 -1
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.d.ts +28 -2
- package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilder.d.ts +5 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.js +132 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +10 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +100 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataTreeContext.d.ts +38 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataTreeContext.js +98 -0
- package/lib/components/ConditionBuilder/assets/sampleInput.d.ts +58 -0
- package/lib/components/ConditionBuilder/index.d.ts +1 -0
- package/lib/components/CreateFullPage/CreateFullPage.d.ts +121 -4
- package/lib/components/CreateFullPage/CreateFullPage.js +13 -25
- package/lib/components/CreateFullPage/CreateFullPageStep.js +20 -5
- package/lib/components/CreateTearsheet/CreateTearsheet.js +2 -0
- package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.d.ts +82 -2
- 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/Datagrid/Datagrid/addons/stateReducer.js +2 -1
- package/lib/components/Datagrid/useEditableCell.js +19 -0
- package/lib/components/DelimitedList/DelimitedList.d.ts +27 -2
- package/lib/components/DelimitedList/DelimitedList.js +0 -1
- package/lib/components/EditFullPage/EditFullPage.d.ts +19 -2
- package/lib/components/EditFullPage/EditFullPage.js +3 -3
- package/lib/components/EditInPlace/EditInPlace.d.ts +97 -5
- package/lib/components/EditInPlace/EditInPlace.js +10 -6
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -3
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -2
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -3
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.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/ExportModal/ExportModal.d.ts +110 -2
- package/lib/components/ExportModal/ExportModal.js +10 -4
- package/lib/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.js +1 -1
- package/lib/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.js +2 -2
- package/lib/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.d.ts +5 -0
- package/lib/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.js +5 -9
- package/lib/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.js +1 -1
- package/lib/components/FilterPanel/FilterPanelSearch/FilterPanelSearch.d.ts +5 -0
- package/lib/components/FilterPanel/FilterPanelSearch/FilterPanelSearch.js +99 -0
- package/lib/components/FilterPanel/index.d.ts +1 -0
- package/lib/components/FullPageError/FullPageError.d.ts +2 -1
- package/lib/components/FullPageError/FullPageError.js +24 -49
- package/lib/components/HTTPErrors/HTTPError403/HTTPError403.d.ts +40 -2
- package/lib/components/HTTPErrors/HTTPError403/HTTPError403.js +1 -1
- package/lib/components/HTTPErrors/HTTPError404/HTTPError404.d.ts +40 -2
- package/lib/components/HTTPErrors/HTTPError404/HTTPError404.js +1 -1
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.d.ts +40 -2
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +1 -1
- package/lib/components/ImportModal/ImportModal.d.ts +136 -2
- package/lib/components/ImportModal/ImportModal.js +3 -2
- package/lib/components/InlineTip/InlineTip.d.ts +90 -2
- package/lib/components/InlineTip/InlineTip.js +3 -2
- 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/Nav/Nav.js +1 -1
- package/lib/components/Nav/NavList.js +7 -7
- package/lib/components/NonLinearReading/NonLinearReading.d.ts +28 -2
- package/lib/components/NonLinearReading/NonLinearReading.js +2 -7
- package/lib/components/NotificationsPanel/NotificationsPanel.js +1 -1
- package/lib/components/PageHeader/PageHeader.js +3 -3
- package/lib/components/PageHeader/PageHeaderUtils.d.ts +1 -1
- package/lib/components/PageHeader/PageHeaderUtils.js +4 -3
- package/lib/components/SearchBar/SearchBar.d.ts +51 -3
- package/lib/components/SearchBar/SearchBar.js +5 -6
- package/lib/components/SidePanel/SidePanel.js +62 -41
- package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.d.ts +23 -2
- package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +6 -5
- package/lib/components/TagOverflow/TagOverflow.d.ts +5 -0
- package/lib/components/TagOverflow/TagOverflow.js +216 -0
- package/lib/components/TagOverflow/constants.d.ts +14 -0
- package/lib/components/TagOverflow/constants.js +34 -0
- package/lib/components/TagOverflow/index.d.ts +1 -0
- package/lib/components/Tearsheet/TearsheetNarrow.d.ts +105 -6
- package/lib/components/Tearsheet/TearsheetNarrow.js +6 -1
- package/lib/components/Toolbar/Toolbar.d.ts +23 -5
- package/lib/components/Toolbar/Toolbar.js +30 -26
- package/lib/components/TruncatedList/TruncatedList.d.ts +47 -2
- package/lib/components/TruncatedList/TruncatedList.js +5 -4
- package/lib/components/UserAvatar/UserAvatar.js +4 -2
- package/lib/components/index.d.ts +4 -2
- package/lib/global/js/package-settings.d.ts +3 -0
- package/lib/global/js/package-settings.js +3 -0
- package/lib/index.js +17 -0
- package/lib/settings.d.ts +3 -0
- package/package.json +5 -5
- package/scss/components/Coachmark/_coachmark-dragbar.scss +0 -1
- package/scss/components/Coachmark/_coachmark-tagline.scss +2 -2
- package/scss/components/ConditionBuilder/_carbon-imports.scss +9 -0
- package/scss/components/ConditionBuilder/_condition-builder.scss +25 -0
- package/scss/components/ConditionBuilder/_index-with-carbon.scss +9 -0
- package/scss/components/ConditionBuilder/_index.scss +8 -0
- package/scss/components/CreateFullPage/_create-full-page.scss +10 -10
- package/scss/components/Datagrid/styles/_useNestedRows.scss +5 -1
- package/scss/components/Datagrid/styles/_useSortableColumns.scss +2 -0
- package/scss/components/FilterPanel/_carbon-imports.scss +5 -0
- package/scss/components/FilterPanel/_filter-panel-accordion-item.scss +1 -3
- package/scss/components/FilterPanel/_filter-panel-checkbox-with-overflow.scss +0 -2
- package/scss/components/FilterPanel/_filter-panel-checkbox.scss +0 -1
- package/scss/components/FilterPanel/_filter-panel-search.scss +38 -0
- package/scss/components/FilterPanel/_index-with-carbon.scss +1 -0
- package/scss/components/FilterPanel/_index.scss +1 -0
- package/scss/components/FullPageError/_full-page-error.scss +10 -10
- package/scss/components/Guidebanner/_guidebanner.scss +1 -1
- package/scss/components/InlineTip/_inline-tip.scss +1 -1
- package/scss/components/ProductiveCard/_productive-card.scss +13 -0
- package/scss/components/SidePanel/_side-panel.scss +9 -9
- package/scss/components/TagOverflow/_carbon-imports.scss +9 -0
- package/scss/components/TagOverflow/_index-with-carbon.scss +9 -0
- package/scss/components/TagOverflow/_index.scss +8 -0
- package/scss/components/TagOverflow/_tag-overflow.scss +55 -0
- package/scss/components/Tearsheet/_tearsheet.scss +10 -0
- package/scss/components/UserAvatar/_user-avatar.scss +7 -3
- package/scss/components/_index-with-carbon.scss +2 -0
- package/scss/components/_index.scss +2 -0
@@ -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.
|
@@ -10,7 +10,6 @@ import React__default, { useState, useRef, useEffect, useCallback } from 'react'
|
|
10
10
|
import { motion, useReducedMotion, AnimatePresence } from 'framer-motion';
|
11
11
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
12
12
|
import cx from 'classnames';
|
13
|
-
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
|
14
13
|
import { moderate02 } from '@carbon/motion';
|
15
14
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
16
15
|
import { allPropTypes } from '../../global/js/utils/props-helper.js';
|
@@ -25,7 +24,7 @@ import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
|
|
25
24
|
import { useFocus } from '../../global/js/hooks/useFocus.js';
|
26
25
|
|
27
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"],
|
28
|
-
_excluded2 = ["label", "kind", "icon", "tooltipPosition", "tooltipAlignment", "leading", "disabled", "className", "onClick"];
|
27
|
+
_excluded2 = ["label", "kind", "hasIconOnly", "icon", "renderIcon", "tooltipPosition", "tooltipAlignment", "leading", "disabled", "className", "onClick"];
|
29
28
|
var blockClass = "".concat(pkg.prefix, "--side-panel");
|
30
29
|
var componentName = 'SidePanel';
|
31
30
|
// `any` is a work around until ActionSet is migrated to TS
|
@@ -110,14 +109,48 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
110
109
|
keyDownListener = _useFocus.keyDownListener;
|
111
110
|
var panelRefValue = sidePanelRef.current;
|
112
111
|
var shouldReduceMotion = useReducedMotion();
|
112
|
+
|
113
|
+
// Title animation on scroll related state
|
114
|
+
var _useState7 = useState(0),
|
115
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
116
|
+
labelTextHeight = _useState8[0],
|
117
|
+
setLabelTextHeight = _useState8[1];
|
118
|
+
useEffect(function () {
|
119
|
+
if (open && !(titleRef !== null && titleRef !== void 0 && titleRef.current)) {
|
120
|
+
setDoAnimateTitle(false);
|
121
|
+
} else {
|
122
|
+
setDoAnimateTitle(animateTitle);
|
123
|
+
}
|
124
|
+
}, [animateTitle, open]);
|
125
|
+
var titleItemsStyles = useCallback(function (progress) {
|
126
|
+
if (subtitleRef !== null && subtitleRef !== void 0 && subtitleRef.current) {
|
127
|
+
var _subtitleEl$style;
|
128
|
+
var subtitleEl = subtitleRef === null || subtitleRef === void 0 ? void 0 : subtitleRef.current;
|
129
|
+
var height = subtitleEl === null || subtitleEl === void 0 ? void 0 : subtitleEl.clientHeight;
|
130
|
+
var calculatedMargin = height * progress;
|
131
|
+
subtitleEl === null || subtitleEl === void 0 || (_subtitleEl$style = subtitleEl.style) === null || _subtitleEl$style === void 0 || _subtitleEl$style.setProperty('margin-top', "".concat(-calculatedMargin, "px"));
|
132
|
+
}
|
133
|
+
if (labelTextRef !== null && labelTextRef !== void 0 && labelTextRef.current) {
|
134
|
+
var _labelTextRef$current;
|
135
|
+
var _calculatedMargin = labelTextHeight * progress;
|
136
|
+
labelTextRef === null || labelTextRef === void 0 || (_labelTextRef$current = labelTextRef.current) === null || _labelTextRef$current === void 0 || (_labelTextRef$current = _labelTextRef$current.style) === null || _labelTextRef$current === void 0 || _labelTextRef$current.setProperty('margin-top', "".concat(-_calculatedMargin, "px"));
|
137
|
+
}
|
138
|
+
}, [labelTextHeight]);
|
113
139
|
useEffect(function () {
|
114
|
-
|
115
|
-
|
140
|
+
if (open && animateTitle && labelTextRef !== null && labelTextRef !== void 0 && labelTextRef.current) {
|
141
|
+
var _labelTextRef$current2;
|
142
|
+
setLabelTextHeight(Number((labelTextRef === null || labelTextRef === void 0 || (_labelTextRef$current2 = labelTextRef.current) === null || _labelTextRef$current2 === void 0 ? void 0 : _labelTextRef$current2.clientHeight) || null));
|
143
|
+
}
|
144
|
+
}, [animateTitle, labelTextRef, open]);
|
116
145
|
var handleScroll = useCallback(function () {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
146
|
+
if (doAnimateTitle && innerContentRef !== null && innerContentRef !== void 0 && innerContentRef.current) {
|
147
|
+
var _innerContentRef$curr;
|
148
|
+
var scrollTop = innerContentRef === null || innerContentRef === void 0 || (_innerContentRef$curr = innerContentRef.current) === null || _innerContentRef$curr === void 0 ? void 0 : _innerContentRef$curr.scrollTop;
|
149
|
+
var animationProgress = Math.min(Number(scrollTop), scrollAnimationDistance) / scrollAnimationDistance;
|
150
|
+
panelRefValue === null || panelRefValue === void 0 || panelRefValue.style.setProperty("--".concat(blockClass, "--scroll-animation-progress"), animationProgress.toString());
|
151
|
+
titleItemsStyles(animationProgress);
|
152
|
+
}
|
153
|
+
}, [doAnimateTitle, panelRefValue === null || panelRefValue === void 0 ? void 0 : panelRefValue.style, scrollAnimationDistance, titleItemsStyles]);
|
121
154
|
var reducedMotion = typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
122
155
|
matches: true
|
123
156
|
};
|
@@ -125,8 +158,8 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
125
158
|
// scroll panel to top going between steps
|
126
159
|
useEffect(function () {
|
127
160
|
if (sidePanelRef && panelRefValue) {
|
128
|
-
var _animatedScrollRef$
|
129
|
-
var scrollableSection = (_animatedScrollRef$
|
161
|
+
var _animatedScrollRef$cu;
|
162
|
+
var scrollableSection = (_animatedScrollRef$cu = animatedScrollRef.current) !== null && _animatedScrollRef$cu !== void 0 ? _animatedScrollRef$cu : innerContentRef.current;
|
130
163
|
if (scrollableSection) {
|
131
164
|
scrollableSection.scrollTop = 0;
|
132
165
|
}
|
@@ -149,9 +182,9 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
149
182
|
var checkSetDoAnimateTitle = function checkSetDoAnimateTitle() {
|
150
183
|
var canDoAnimateTitle = false;
|
151
184
|
if (panelRefValue && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !reducedMotion.matches) {
|
152
|
-
var _labelTextRef$
|
185
|
+
var _labelTextRef$current3, _labelTextRef$current4, _subtitleRef$current$, _subtitleRef$current;
|
153
186
|
var titleEl = titleRef.current;
|
154
|
-
var labelHeight = (_labelTextRef$
|
187
|
+
var labelHeight = (_labelTextRef$current3 = labelTextRef === null || labelTextRef === void 0 || (_labelTextRef$current4 = labelTextRef.current) === null || _labelTextRef$current4 === void 0 ? void 0 : _labelTextRef$current4.offsetHeight) !== null && _labelTextRef$current3 !== void 0 ? _labelTextRef$current3 : 0;
|
155
188
|
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;
|
156
189
|
|
157
190
|
// Adjusts space at bottom of titles by changing where scrolling finishes
|
@@ -162,11 +195,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
162
195
|
|
163
196
|
// used to calculate the header moves
|
164
197
|
panelRefValue === null || panelRefValue === void 0 || panelRefValue.style.setProperty("--".concat(blockClass, "--scroll-animation-distance"), _scrollAnimationDistance.toString());
|
165
|
-
var scrollEl =
|
166
|
-
if (!scrollEl && animateTitle && !doAnimateTitle) {
|
167
|
-
// may be switching back based on resize
|
168
|
-
scrollEl = innerContentRef.current;
|
169
|
-
}
|
198
|
+
var scrollEl = innerContentRef.current;
|
170
199
|
if (scrollEl) {
|
171
200
|
var _window2;
|
172
201
|
var innerComputed = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.getComputedStyle(innerContentRef.current);
|
@@ -180,20 +209,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
180
209
|
}
|
181
210
|
};
|
182
211
|
useEffect(function () {
|
183
|
-
if (doAnimateTitle && animatedScrollRef.current) {
|
184
|
-
// only add scroll if the doAnimateTitle is already true
|
185
|
-
// should come back through if false and canDoAnimateTitle is true
|
186
|
-
animatedScrollRef.current.addEventListener('scroll', handleScroll);
|
187
|
-
}
|
188
212
|
if (!doAnimateTitle && sidePanelRef.current) {
|
189
213
|
panelRefValue === null || panelRefValue === void 0 || panelRefValue.style.setProperty("--".concat(blockClass, "--scroll-animation-progress"), '0');
|
190
214
|
}
|
191
|
-
}, [
|
192
|
-
|
193
|
-
/* istanbul ignore next */
|
194
|
-
var handleResize = function handleResize() {
|
195
|
-
checkSetDoAnimateTitle();
|
196
|
-
};
|
215
|
+
}, [doAnimateTitle, handleScroll, sidePanelRef, innerContentRef, open, panelRefValue === null || panelRefValue === void 0 ? void 0 : panelRefValue.style]);
|
197
216
|
|
198
217
|
// Calculate scroll distances
|
199
218
|
useEffect(function () {
|
@@ -202,7 +221,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
202
221
|
}
|
203
222
|
|
204
223
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
205
|
-
}, [open, doAnimateTitle /* use do instead of animateTitle directly */, animationComplete, handleScroll, title, size, reducedMotion.matches, id
|
224
|
+
}, [open, doAnimateTitle /* use do instead of animateTitle directly */, animationComplete, handleScroll, title, size, reducedMotion.matches, id]);
|
206
225
|
|
207
226
|
// click outside functionality if `includeOverlay` prop is set
|
208
227
|
useEffect(function () {
|
@@ -301,7 +320,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
301
320
|
}
|
302
321
|
}, [animationComplete, firstElement, open, selectorPrimaryFocus]);
|
303
322
|
var primaryActionContainerClassNames = cx(["".concat(blockClass, "__actions-container"), _defineProperty({}, "".concat(blockClass, "__actions-container--condensed"), condensedActions)]);
|
304
|
-
var mainPanelClassNames = cx([blockClass, className, "".concat(blockClass), "".concat(blockClass, "--").concat(size), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(
|
323
|
+
var mainPanelClassNames = cx([blockClass, className, "".concat(blockClass), "".concat(blockClass, "--").concat(size), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "--right-placement"), placement === 'right'), "".concat(blockClass, "--left-placement"), placement === 'left'), "".concat(blockClass, "--slide-in"), slideIn), "".concat(blockClass, "--has-slug"), slug), "".concat(blockClass, "--condensed-actions"), condensedActions), "".concat(blockClass, "--has-overlay"), includeOverlay)]);
|
305
324
|
var renderTitle = function renderTitle() {
|
306
325
|
return /*#__PURE__*/React__default.createElement("div", {
|
307
326
|
className: cx("".concat(blockClass, "__title"), _defineProperty({}, "".concat(blockClass, "__title--no-label"), !labelTextRef.current)),
|
@@ -368,7 +387,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
368
387
|
}, actionToolbarButtons.map(function (_ref4) {
|
369
388
|
var label = _ref4.label,
|
370
389
|
kind = _ref4.kind,
|
390
|
+
_ref4$hasIconOnly = _ref4.hasIconOnly,
|
391
|
+
hasIconOnly = _ref4$hasIconOnly === void 0 ? false : _ref4$hasIconOnly,
|
371
392
|
icon = _ref4.icon,
|
393
|
+
renderIcon = _ref4.renderIcon,
|
372
394
|
tooltipPosition = _ref4.tooltipPosition,
|
373
395
|
tooltipAlignment = _ref4.tooltipAlignment,
|
374
396
|
leading = _ref4.leading,
|
@@ -380,11 +402,13 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
380
402
|
key: label,
|
381
403
|
kind: kind || 'ghost',
|
382
404
|
size: "sm",
|
383
|
-
renderIcon: icon,
|
384
|
-
iconDescription: label
|
405
|
+
renderIcon: renderIcon || icon,
|
406
|
+
iconDescription: label
|
407
|
+
}, hasIconOnly && {
|
385
408
|
tooltipPosition: tooltipPosition || 'bottom',
|
386
|
-
tooltipAlignment: tooltipAlignment || 'start'
|
387
|
-
|
409
|
+
tooltipAlignment: tooltipAlignment || 'start'
|
410
|
+
}, {
|
411
|
+
hasIconOnly: hasIconOnly,
|
388
412
|
disabled: disabled,
|
389
413
|
className: cx(["".concat(blockClass, "__action-toolbar-button"), className, _defineProperty({}, "".concat(blockClass, "__action-toolbar-leading-button"), leading)]),
|
390
414
|
onClick: onClick
|
@@ -394,10 +418,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
394
418
|
var renderMain = function renderMain() {
|
395
419
|
return /*#__PURE__*/React__default.createElement("div", {
|
396
420
|
ref: innerContentRef,
|
397
|
-
|
421
|
+
onScroll: handleScroll,
|
422
|
+
className: cx("".concat(blockClass, "__inner-content"), "".concat(blockClass, "--scrolls"), "".concat(!doAnimateTitle ? "".concat(blockClass, "__inner-content--no-animated-title") : ''))
|
398
423
|
}, children);
|
399
424
|
};
|
400
|
-
useResizeObserver(sidePanelRef, handleResize, [open]);
|
401
425
|
return /*#__PURE__*/React__default.createElement(AnimatePresence, null, open && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(motion.div, _extends({}, getDevtoolsProps(componentName), rest, {
|
402
426
|
id: id,
|
403
427
|
className: mainPanelClassNames,
|
@@ -415,11 +439,8 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
415
439
|
shouldReduceMotion: shouldReduceMotion
|
416
440
|
},
|
417
441
|
onKeyDown: keyDownListener
|
418
|
-
}),
|
419
|
-
|
420
|
-
className: "".concat(blockClass, "__animated-scroll-wrapper ").concat(blockClass, "--scrolls")
|
421
|
-
}, renderHeader(), renderMain()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(MotionActionSet, {
|
422
|
-
actions: actions,
|
442
|
+
}), /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(MotionActionSet, {
|
443
|
+
actions: actions !== null && actions !== void 0 ? actions : [],
|
423
444
|
className: primaryActionContainerClassNames,
|
424
445
|
size: size === 'xs' ? 'sm' : size,
|
425
446
|
custom: shouldReduceMotion,
|
@@ -1,5 +1,26 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* Copyright IBM Corp. 2023, 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
|
-
export const SteppedAnimatedMedia: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
5
7
|
import React from 'react';
|
8
|
+
interface SteppedAnimatedMediaProps {
|
9
|
+
/**
|
10
|
+
* Optional class name for this component.
|
11
|
+
*/
|
12
|
+
className?: string;
|
13
|
+
/**
|
14
|
+
* The file path(s) to json formatted Lottie animation files.
|
15
|
+
*/
|
16
|
+
filePaths: string[] | undefined;
|
17
|
+
/**
|
18
|
+
* Which animation step from the filePaths array to play.
|
19
|
+
*/
|
20
|
+
playStep?: number;
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* The SteppedAnimatedMedia is a Novice to Pro internal component and is not intended for general use.
|
24
|
+
*/
|
25
|
+
export declare const SteppedAnimatedMedia: React.ForwardRefExoticComponent<SteppedAnimatedMediaProps & React.RefAttributes<HTMLDivElement>>;
|
26
|
+
export {};
|
@@ -26,7 +26,6 @@ var componentName = 'SteppedAnimatedMedia';
|
|
26
26
|
var defaults = {
|
27
27
|
playStep: 0
|
28
28
|
};
|
29
|
-
|
30
29
|
/**
|
31
30
|
* The SteppedAnimatedMedia is a Novice to Pro internal component and is not intended for general use.
|
32
31
|
*/
|
@@ -41,8 +40,9 @@ var SteppedAnimatedMedia = /*#__PURE__*/React__default.forwardRef(function (_ref
|
|
41
40
|
jsonData = _useState2[0],
|
42
41
|
setJsonData = _useState2[1];
|
43
42
|
var animRef = useRef();
|
44
|
-
var backupRef = useRef();
|
43
|
+
var backupRef = useRef(null);
|
45
44
|
var localRef = ref !== null && ref !== void 0 ? ref : backupRef;
|
45
|
+
var localRefValue = localRef.current;
|
46
46
|
// load animation source
|
47
47
|
useEffect(function () {
|
48
48
|
var isJsonFile = function isJsonFile(filePath) {
|
@@ -89,11 +89,11 @@ var SteppedAnimatedMedia = /*#__PURE__*/React__default.forwardRef(function (_ref
|
|
89
89
|
useEffect(function () {
|
90
90
|
var _window;
|
91
91
|
var prefersReducedMotion = (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)').matches : true;
|
92
|
-
if (
|
92
|
+
if (localRefValue) {
|
93
93
|
var _animRef$current, _animRef$current2, _animRef$current3;
|
94
94
|
(_animRef$current = animRef.current) === null || _animRef$current === void 0 || _animRef$current.destroy();
|
95
95
|
animRef.current = lottie.loadAnimation({
|
96
|
-
container:
|
96
|
+
container: localRefValue,
|
97
97
|
renderer: 'svg',
|
98
98
|
animationData: jsonData[clamp(playStep, 0, jsonData.length - 1)],
|
99
99
|
loop: false,
|
@@ -108,7 +108,7 @@ var SteppedAnimatedMedia = /*#__PURE__*/React__default.forwardRef(function (_ref
|
|
108
108
|
var _animRef$current4;
|
109
109
|
return (_animRef$current4 = animRef.current) === null || _animRef$current4 === void 0 ? void 0 : _animRef$current4.destroy();
|
110
110
|
};
|
111
|
-
}, [jsonData,
|
111
|
+
}, [jsonData, localRefValue, playStep]);
|
112
112
|
if (!jsonData) {
|
113
113
|
return null;
|
114
114
|
}
|
@@ -127,6 +127,7 @@ SteppedAnimatedMedia.propTypes = {
|
|
127
127
|
/**
|
128
128
|
* The file path(s) to json formatted Lottie animation files.
|
129
129
|
*/
|
130
|
+
/**@ts-ignore*/
|
130
131
|
filePaths: PropTypes.arrayOf(PropTypes.string).isRequired,
|
131
132
|
/**
|
132
133
|
* Which animation step from the filePaths array to play.
|
@@ -0,0 +1,209 @@
|
|
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, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default, { useRef, useState, useCallback, useEffect } from 'react';
|
10
|
+
import PropTypes from '../../node_modules/prop-types/index.js';
|
11
|
+
import cx from 'classnames';
|
12
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
13
|
+
import { pkg } from '../../settings.js';
|
14
|
+
import { Tooltip, Tag } from '@carbon/react';
|
15
|
+
import { TYPES } from './constants.js';
|
16
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
|
17
|
+
import { TagSet } from '../TagSet/TagSet.js';
|
18
|
+
|
19
|
+
var _excluded = ["className", "items", "tagComponent", "maxVisible", "multiline"],
|
20
|
+
_excluded2 = ["className", "id"];
|
21
|
+
var blockClass = "".concat(pkg.prefix, "--tag-overflow");
|
22
|
+
var componentName = 'TagOverflow';
|
23
|
+
|
24
|
+
// Default values for props
|
25
|
+
var defaults = {
|
26
|
+
items: []
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* TODO: A description of the component.
|
31
|
+
*/
|
32
|
+
var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
33
|
+
var className = _ref.className,
|
34
|
+
_ref$items = _ref.items,
|
35
|
+
items = _ref$items === void 0 ? defaults.items : _ref$items,
|
36
|
+
tagComponent = _ref.tagComponent,
|
37
|
+
maxVisible = _ref.maxVisible,
|
38
|
+
multiline = _ref.multiline,
|
39
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
40
|
+
var localContainerRef = useRef(null);
|
41
|
+
var containerRef = ref || localContainerRef;
|
42
|
+
var itemRefs = useRef(null);
|
43
|
+
var overflowRef = useRef(null);
|
44
|
+
// measurementOffset is the value of margin applied on each items
|
45
|
+
// This value is required for calculating how many items will fit within the container
|
46
|
+
var measurementOffset = 4;
|
47
|
+
var overflowIndicatorWidth = 40;
|
48
|
+
var _useState = useState(0),
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
50
|
+
containerWidth = _useState2[0],
|
51
|
+
setContainerWidth = _useState2[1];
|
52
|
+
var _useState3 = useState([]),
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
54
|
+
visibleItems = _useState4[0],
|
55
|
+
setVisibleItems = _useState4[1];
|
56
|
+
var _useState5 = useState([]),
|
57
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
58
|
+
overflowItems = _useState6[0],
|
59
|
+
setOverflowItems = _useState6[1];
|
60
|
+
var handleResize = function handleResize() {
|
61
|
+
setContainerWidth(containerRef.current.offsetWidth);
|
62
|
+
};
|
63
|
+
useResizeObserver(containerRef, handleResize);
|
64
|
+
var getMap = function getMap() {
|
65
|
+
if (!itemRefs.current) {
|
66
|
+
itemRefs.current = new Map();
|
67
|
+
}
|
68
|
+
return itemRefs.current;
|
69
|
+
};
|
70
|
+
var itemRefHandler = function itemRefHandler(id, node) {
|
71
|
+
var map = getMap();
|
72
|
+
if (id && node && map.get(id) !== node.offsetWidth) {
|
73
|
+
map.set(id, node.offsetWidth);
|
74
|
+
}
|
75
|
+
};
|
76
|
+
var getVisibleItems = useCallback(function () {
|
77
|
+
if (!itemRefs.current) {
|
78
|
+
return items;
|
79
|
+
}
|
80
|
+
if (multiline) {
|
81
|
+
var _visibleItems = maxVisible ? items === null || items === void 0 ? void 0 : items.slice(0, maxVisible) : items;
|
82
|
+
return _visibleItems;
|
83
|
+
}
|
84
|
+
var map = getMap();
|
85
|
+
var overflowContainerWidth = overflowRef.current.offsetWidth > overflowIndicatorWidth ? overflowRef.current.offsetWidth : overflowIndicatorWidth;
|
86
|
+
var maxWidth = containerWidth - overflowContainerWidth;
|
87
|
+
var childrenWidth = 0;
|
88
|
+
var maxReached = false;
|
89
|
+
return items.reduce(function (prev, cur) {
|
90
|
+
if (!maxReached) {
|
91
|
+
var itemWidth = map.get(cur.id) + measurementOffset;
|
92
|
+
var fits = itemWidth + childrenWidth < maxWidth;
|
93
|
+
if (fits) {
|
94
|
+
childrenWidth += itemWidth;
|
95
|
+
prev.push(cur);
|
96
|
+
} else {
|
97
|
+
maxReached = true;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return prev;
|
101
|
+
}, []);
|
102
|
+
}, [itemRefs, overflowRef, containerWidth, items, multiline, maxVisible]);
|
103
|
+
var getCustomComponent = function getCustomComponent(item) {
|
104
|
+
var className = item.className,
|
105
|
+
id = item.id,
|
106
|
+
other = _objectWithoutProperties(item, _excluded2);
|
107
|
+
return /*#__PURE__*/React__default.createElement(tagComponent, _objectSpread2(_objectSpread2({}, other), {}, {
|
108
|
+
className: cx("".concat(blockClass, "__item"), className),
|
109
|
+
ref: function ref(node) {
|
110
|
+
return itemRefHandler(id, node);
|
111
|
+
}
|
112
|
+
}));
|
113
|
+
};
|
114
|
+
useEffect(function () {
|
115
|
+
var visibleItemsArr = getVisibleItems();
|
116
|
+
if (maxVisible && maxVisible < visibleItemsArr.length) {
|
117
|
+
var _visibleItemsArr;
|
118
|
+
visibleItemsArr = (_visibleItemsArr = visibleItemsArr) === null || _visibleItemsArr === void 0 ? void 0 : _visibleItemsArr.slice(0, maxVisible);
|
119
|
+
}
|
120
|
+
var hiddenItems = items === null || items === void 0 ? void 0 : items.slice(visibleItemsArr.length);
|
121
|
+
var overflowItemsArr = hiddenItems === null || hiddenItems === void 0 ? void 0 : hiddenItems.map(function (item) {
|
122
|
+
return {
|
123
|
+
type: item.tagType,
|
124
|
+
label: item.label
|
125
|
+
};
|
126
|
+
});
|
127
|
+
setVisibleItems(visibleItemsArr);
|
128
|
+
setOverflowItems(overflowItemsArr);
|
129
|
+
}, [containerWidth, items, maxVisible, getVisibleItems]);
|
130
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
131
|
+
className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "--multiline"), multiline)),
|
132
|
+
ref: containerRef,
|
133
|
+
role: "main"
|
134
|
+
}, getDevtoolsProps(componentName)), visibleItems.length > 0 && visibleItems.map(function (item) {
|
135
|
+
// Render custom components
|
136
|
+
if (tagComponent) {
|
137
|
+
return getCustomComponent(item);
|
138
|
+
} else {
|
139
|
+
// If there is no template prop, then render items as Tags
|
140
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
141
|
+
ref: function ref(node) {
|
142
|
+
return itemRefHandler(item.id, node);
|
143
|
+
},
|
144
|
+
key: item.id
|
145
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
146
|
+
align: "bottom",
|
147
|
+
label: item.label
|
148
|
+
}, /*#__PURE__*/React__default.createElement(Tag, {
|
149
|
+
className: "".concat(blockClass, "__item--tag"),
|
150
|
+
type: item.tagType
|
151
|
+
}, item.label)));
|
152
|
+
}
|
153
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
154
|
+
className: "".concat(blockClass, "__indicator"),
|
155
|
+
ref: overflowRef
|
156
|
+
}, overflowItems.length > 0 && /*#__PURE__*/React__default.createElement(TagSet, {
|
157
|
+
tags: overflowItems,
|
158
|
+
allTagsModalTitle: "All tags",
|
159
|
+
containingElementRef: overflowRef,
|
160
|
+
allTagsModalSearchLabel: "Search all tags",
|
161
|
+
allTagsModalSearchPlaceholderText: "Search all tags",
|
162
|
+
showAllTagsLabel: "Show all tags"
|
163
|
+
})));
|
164
|
+
});
|
165
|
+
|
166
|
+
// Return a placeholder if not released and not enabled by feature flag
|
167
|
+
TagOverflow = pkg.checkComponentEnabled(TagOverflow, componentName);
|
168
|
+
|
169
|
+
// The display name of the component, used by React. Note that displayName
|
170
|
+
// is used in preference to relying on function.name.
|
171
|
+
TagOverflow.displayName = componentName;
|
172
|
+
var tagTypes = Object.keys(TYPES);
|
173
|
+
|
174
|
+
// The types and DocGen commentary for the component props,
|
175
|
+
// in alphabetical order (for consistency).
|
176
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
177
|
+
TagOverflow.propTypes = {
|
178
|
+
/**
|
179
|
+
* Provide an optional class to be applied to the containing node.
|
180
|
+
*/
|
181
|
+
className: PropTypes.string,
|
182
|
+
/**
|
183
|
+
* The items to be shown in the TagOverflow. Each item is specified as an object with properties:
|
184
|
+
* **label**\* (required) to supply the item content,
|
185
|
+
* **id**\* (required) to uniquely identify the each item.
|
186
|
+
* **tagType** the type value to be passed to the Carbon Tag component
|
187
|
+
* if you are passing an tagComponent prop for rendering custom components,
|
188
|
+
* then pass the props required for your custom component as the properties of item object
|
189
|
+
*/
|
190
|
+
items: PropTypes.arrayOf(PropTypes.shape({
|
191
|
+
id: PropTypes.string.isRequired,
|
192
|
+
label: PropTypes.string.isRequired,
|
193
|
+
tagType: PropTypes.oneOf(tagTypes)
|
194
|
+
}).isRequired),
|
195
|
+
/**
|
196
|
+
* maximum visible items
|
197
|
+
*/
|
198
|
+
maxVisible: PropTypes.number,
|
199
|
+
/**
|
200
|
+
* display items in multiple lines
|
201
|
+
*/
|
202
|
+
multiline: PropTypes.bool,
|
203
|
+
/** Component definition of the items to be rendered inside TagOverflow.
|
204
|
+
* If this is not passed, items will be rendered as Tag component
|
205
|
+
*/
|
206
|
+
tagComponent: PropTypes.elementType
|
207
|
+
};
|
208
|
+
|
209
|
+
export { TagOverflow };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export const TYPES: {
|
2
|
+
red: string;
|
3
|
+
magenta: string;
|
4
|
+
purple: string;
|
5
|
+
blue: string;
|
6
|
+
cyan: string;
|
7
|
+
teal: string;
|
8
|
+
green: string;
|
9
|
+
gray: string;
|
10
|
+
'cool-gray': string;
|
11
|
+
'warm-gray': string;
|
12
|
+
'high-contrast': string;
|
13
|
+
outline: string;
|
14
|
+
};
|
@@ -0,0 +1,30 @@
|
|
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
|
+
// Copyright IBM Corp. 2024, 2024
|
9
|
+
//
|
10
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
11
|
+
// LICENSE file in the root directory of this source tree.
|
12
|
+
//
|
13
|
+
|
14
|
+
// Copied from @carbon/react/es/components/Tag/Tag.js
|
15
|
+
var TYPES = {
|
16
|
+
red: 'Red',
|
17
|
+
magenta: 'Magenta',
|
18
|
+
purple: 'Purple',
|
19
|
+
blue: 'Blue',
|
20
|
+
cyan: 'Cyan',
|
21
|
+
teal: 'Teal',
|
22
|
+
green: 'Green',
|
23
|
+
gray: 'Gray',
|
24
|
+
'cool-gray': 'Cool-Gray',
|
25
|
+
'warm-gray': 'Warm-Gray',
|
26
|
+
'high-contrast': 'High-Contrast',
|
27
|
+
outline: 'Outline'
|
28
|
+
};
|
29
|
+
|
30
|
+
export { TYPES };
|
@@ -0,0 +1 @@
|
|
1
|
+
export { TagOverflow } from "./TagOverflow";
|