@carbon/ibm-products 2.71.0 → 2.72.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/carbon.css +50 -0
- package/css/carbon.css.map +1 -1
- package/css/index-full-carbon.css +560 -185
- 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 +132 -1
- 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 +570 -245
- 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 +358 -33
- 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 → BigNumber/BigNumber.d.ts} +5 -5
- package/es/components/{BigNumbers/BigNumbers.js → BigNumber/BigNumber.js} +12 -12
- package/es/components/BigNumber/BigNumberSkeleton.d.ts +17 -0
- package/es/components/{BigNumbers/BigNumbersSkeleton.js → BigNumber/BigNumberSkeleton.js} +16 -16
- package/es/components/{BigNumbers → BigNumber}/constants.d.ts +3 -3
- package/es/components/{BigNumbers → BigNumber}/constants.js +6 -6
- package/es/components/{BigNumbers → BigNumber}/index.d.ts +2 -2
- package/es/components/Coachmark/next/Coachmark/Coachmark.d.ts +72 -0
- package/es/components/Coachmark/next/Coachmark/Coachmark.js +185 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBeacon/CoachmarkBeacon.d.ts +44 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBeacon/index.d.ts +8 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.d.ts +38 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +125 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.d.ts +24 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.js +25 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/index.d.ts +10 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkContent.d.ts +34 -0
- package/es/components/Coachmark/next/Coachmark/CoachmarkContent.js +118 -0
- package/es/components/Coachmark/next/Coachmark/ContentBody.d.ts +23 -0
- package/es/components/Coachmark/next/Coachmark/ContentBody.js +37 -0
- package/es/components/Coachmark/next/Coachmark/ContentHeader.d.ts +21 -0
- package/es/components/Coachmark/next/Coachmark/ContentHeader.js +89 -0
- package/{lib/components/BigNumbers → es/components/Coachmark/next/Coachmark}/index.d.ts +2 -2
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +0 -1
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -5
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +11 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +1 -1
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +42 -3
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +5 -3
- package/es/components/ConditionBuilder/utils/useTranslations.js +1 -1
- package/es/components/EditInPlace/EditInPlace.js +0 -3
- package/es/components/EmptyStates/EmptyState.d.ts +2 -2
- package/es/components/EmptyStates/EmptyState.js +2 -8
- package/es/components/FilterPanel/FilterPanelGroup/index.d.ts +1 -0
- package/es/components/InterstitialScreen/InterstitialScreen.d.ts +1 -25
- package/es/components/InterstitialScreen/InterstitialScreen.js +3 -19
- package/es/components/InterstitialScreen/InterstitialScreenBody.d.ts +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenBody.js +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenFooter.d.ts +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenFooter.js +1 -1
- package/es/components/InterstitialScreen/InterstitialScreenHeader.d.ts +6 -0
- package/es/components/InterstitialScreen/InterstitialScreenHeader.js +1 -1
- package/es/components/InterstitialScreen/_story-assets/InterstitialScreenViewModule/InterstitialScreenViewModule.d.ts +1 -1
- package/es/components/InterstitialScreen/context.d.ts +31 -0
- package/es/components/InterstitialScreen/context.js +18 -0
- package/es/components/InterstitialScreen/index.d.ts +3 -2
- package/es/components/NotificationsPanel/NotificationsPanel.js +36 -13
- package/es/components/PageHeader/PageHeader.d.ts +2 -1
- package/es/components/PageHeader/PageHeader.js +2 -1
- package/es/components/PageHeader/next/PageHeader.d.ts +18 -3
- package/es/components/PageHeader/next/PageHeader.js +260 -12
- package/es/components/PageHeader/next/context.d.ts +25 -0
- package/es/components/PageHeader/next/context.js +30 -0
- package/es/components/PageHeader/next/index.d.ts +3 -3
- package/es/components/PageHeader/next/overflowHandler.d.ts +95 -0
- package/es/components/PageHeader/next/overflowHandler.js +162 -0
- package/es/components/PageHeader/next/utils.d.ts +19 -0
- package/es/components/PageHeader/next/utils.js +68 -0
- package/es/components/ProductiveCard/ProductiveCard.js +2 -1
- package/es/components/ScrollGradient/ScrollGradient.js +1 -2
- package/es/components/SidePanel/SidePanel.d.ts +4 -0
- package/es/components/SidePanel/SidePanel.js +8 -2
- package/es/components/Tearsheet/TearsheetShell.js +8 -5
- package/es/components/TruncatedText/TruncatedText.d.ts +48 -0
- package/es/components/TruncatedText/TruncatedText.js +86 -0
- package/es/components/TruncatedText/index.d.ts +7 -0
- package/es/components/TruncatedText/useTruncatedText.d.ts +16 -0
- package/es/components/TruncatedText/useTruncatedText.js +41 -0
- package/es/components/index.d.ts +4 -2
- package/es/global/js/hooks/useOverflowString.d.ts +2 -2
- package/es/global/js/hooks/useResizeObserver.d.ts +1 -1
- package/es/global/js/package-settings.d.ts +2 -1
- package/es/global/js/package-settings.js +3 -2
- package/es/global/js/utils/checkForOverflow.js +21 -0
- package/es/global/js/utils/makeDraggable/index.d.ts +1 -0
- package/es/global/js/utils/makeDraggable/makeDraggable.d.ts +19 -0
- package/es/global/js/utils/makeDraggable/makeDraggable.js +91 -0
- package/es/global/js/utils/makeDraggable/makeDraggable.stories.d.ts +22 -0
- package/es/index.js +4 -2
- package/es/node_modules/@floating-ui/core/dist/floating-ui.core.js +592 -0
- package/es/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +713 -0
- package/es/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +95 -0
- package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +161 -0
- package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +142 -0
- package/es/settings.d.ts +2 -1
- package/lib/components/{BigNumbers/BigNumbers.d.ts → BigNumber/BigNumber.d.ts} +5 -5
- package/lib/components/{BigNumbers/BigNumbers.js → BigNumber/BigNumber.js} +11 -11
- package/lib/components/BigNumber/BigNumberSkeleton.d.ts +17 -0
- package/lib/components/{BigNumbers/BigNumbersSkeleton.js → BigNumber/BigNumberSkeleton.js} +15 -15
- package/lib/components/{BigNumbers → BigNumber}/constants.d.ts +3 -3
- package/lib/components/{BigNumbers → BigNumber}/constants.js +6 -6
- package/lib/components/BigNumber/index.d.ts +7 -0
- package/lib/components/Coachmark/Coachmark.js +2 -2
- package/lib/components/Coachmark/next/Coachmark/Coachmark.d.ts +72 -0
- package/lib/components/Coachmark/next/Coachmark/Coachmark.js +189 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBeacon/CoachmarkBeacon.d.ts +44 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBeacon/index.d.ts +8 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.d.ts +38 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +127 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.d.ts +24 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubbleHeader.js +27 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/index.d.ts +10 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkContent.d.ts +34 -0
- package/lib/components/Coachmark/next/Coachmark/CoachmarkContent.js +122 -0
- package/lib/components/Coachmark/next/Coachmark/ContentBody.d.ts +23 -0
- package/lib/components/Coachmark/next/Coachmark/ContentBody.js +41 -0
- package/lib/components/Coachmark/next/Coachmark/ContentHeader.d.ts +21 -0
- package/lib/components/Coachmark/next/Coachmark/ContentHeader.js +93 -0
- package/lib/components/Coachmark/next/Coachmark/index.d.ts +7 -0
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +0 -1
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +2 -2
- package/lib/components/CoachmarkStack/CoachmarkStack.js +2 -2
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -5
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +11 -4
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +1 -1
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +41 -2
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +5 -3
- package/lib/components/ConditionBuilder/utils/useTranslations.js +1 -1
- package/lib/components/EditInPlace/EditInPlace.js +0 -3
- package/lib/components/EmptyStates/EmptyState.d.ts +2 -2
- package/lib/components/EmptyStates/EmptyState.js +2 -8
- package/lib/components/FilterPanel/FilterPanelGroup/index.d.ts +1 -0
- package/lib/components/InterstitialScreen/InterstitialScreen.d.ts +1 -25
- package/lib/components/InterstitialScreen/InterstitialScreen.js +6 -25
- package/lib/components/InterstitialScreen/InterstitialScreenBody.d.ts +1 -1
- package/lib/components/InterstitialScreen/InterstitialScreenBody.js +6 -6
- package/lib/components/InterstitialScreen/InterstitialScreenFooter.d.ts +1 -1
- package/lib/components/InterstitialScreen/InterstitialScreenFooter.js +9 -9
- package/lib/components/InterstitialScreen/InterstitialScreenHeader.d.ts +6 -0
- package/lib/components/InterstitialScreen/InterstitialScreenHeader.js +5 -5
- package/lib/components/InterstitialScreen/_story-assets/InterstitialScreenViewModule/InterstitialScreenViewModule.d.ts +1 -1
- package/lib/components/InterstitialScreen/context.d.ts +31 -0
- package/lib/components/InterstitialScreen/context.js +21 -0
- package/lib/components/InterstitialScreen/index.d.ts +3 -2
- package/lib/components/NotificationsPanel/NotificationsPanel.js +36 -13
- package/lib/components/PageHeader/PageHeader.d.ts +2 -1
- package/lib/components/PageHeader/PageHeader.js +2 -1
- package/lib/components/PageHeader/next/PageHeader.d.ts +18 -3
- package/lib/components/PageHeader/next/PageHeader.js +261 -7
- package/lib/components/PageHeader/next/context.d.ts +25 -0
- package/lib/components/PageHeader/next/context.js +33 -0
- package/lib/components/PageHeader/next/index.d.ts +3 -3
- package/lib/components/PageHeader/next/overflowHandler.d.ts +95 -0
- package/lib/components/PageHeader/next/overflowHandler.js +166 -0
- package/lib/components/PageHeader/next/utils.d.ts +19 -0
- package/lib/components/PageHeader/next/utils.js +71 -0
- package/lib/components/ProductiveCard/ProductiveCard.js +2 -1
- package/lib/components/ScrollGradient/ScrollGradient.js +1 -2
- package/lib/components/SidePanel/SidePanel.d.ts +4 -0
- package/lib/components/SidePanel/SidePanel.js +8 -2
- package/lib/components/Tearsheet/TearsheetShell.js +8 -5
- package/lib/components/TruncatedText/TruncatedText.d.ts +48 -0
- package/lib/components/TruncatedText/TruncatedText.js +86 -0
- package/lib/components/TruncatedText/index.d.ts +7 -0
- package/lib/components/TruncatedText/useTruncatedText.d.ts +16 -0
- package/lib/components/TruncatedText/useTruncatedText.js +45 -0
- package/lib/components/index.d.ts +4 -2
- package/lib/global/js/hooks/useOverflowString.d.ts +2 -2
- package/lib/global/js/hooks/usePortalTarget.js +2 -2
- package/lib/global/js/hooks/useResizeObserver.d.ts +1 -1
- package/lib/global/js/package-settings.d.ts +2 -1
- package/lib/global/js/package-settings.js +3 -2
- package/lib/global/js/utils/checkForOverflow.js +23 -0
- package/lib/global/js/utils/makeDraggable/index.d.ts +1 -0
- package/lib/global/js/utils/makeDraggable/makeDraggable.d.ts +19 -0
- package/lib/global/js/utils/makeDraggable/makeDraggable.js +93 -0
- package/lib/global/js/utils/makeDraggable/makeDraggable.stories.d.ts +22 -0
- package/lib/index.js +11 -4
- package/lib/node_modules/@floating-ui/core/dist/floating-ui.core.js +600 -0
- package/lib/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +722 -0
- package/lib/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +102 -0
- package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +182 -0
- package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +164 -0
- package/lib/settings.d.ts +2 -1
- package/package.json +10 -11
- package/scss/components/{BigNumbers/_big-numbers.scss → BigNumber/_big-number.scss} +5 -5
- package/scss/components/{BigNumbers → BigNumber}/_carbon-imports.scss +3 -3
- package/scss/components/{BigNumbers → BigNumber}/_index-with-carbon.scss +2 -2
- package/scss/components/{BigNumbers → BigNumber}/_index.scss +2 -2
- package/scss/components/Card/_card.scss +2 -0
- package/scss/components/Coachmark/_bubble.scss +62 -0
- package/scss/components/Coachmark/_coachmark-beacon.scss +164 -0
- package/scss/components/Coachmark/_coachmark.scss +15 -0
- package/scss/components/ConditionBuilder/_condition-builder.scss +8 -0
- package/scss/components/PageHeader/_page-header.scss +144 -1
- package/scss/components/Tearsheet/_tearsheet.scss +6 -0
- package/scss/components/TruncatedText/_carbon-imports.scss +6 -0
- package/scss/components/TruncatedText/_index-with-carbon.scss +9 -0
- package/scss/components/TruncatedText/_index.scss +8 -0
- package/scss/components/TruncatedText/_truncated-text.scss +26 -0
- package/scss/components/_index-with-carbon.scss +3 -2
- package/scss/components/_index.scss +3 -2
- package/telemetry.yml +24 -5
- package/es/components/BigNumbers/BigNumbersSkeleton.d.ts +0 -17
- package/lib/components/BigNumbers/BigNumbersSkeleton.d.ts +0 -17
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2025
|
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
|
+
* ----------
|
9
|
+
* Utilities
|
10
|
+
* ----------
|
11
|
+
*/
|
12
|
+
export declare const getHeaderOffset: (el: HTMLElement) => number;
|
13
|
+
/**
|
14
|
+
* Walks up the parent nodes to identify the first scrollable ancestor
|
15
|
+
*
|
16
|
+
* @param {HTMLElement} target
|
17
|
+
* @returns {HTMLElement}
|
18
|
+
*/
|
19
|
+
export declare const scrollableAncestor: (target: HTMLElement) => ParentNode | null;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2025
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* ----------
|
12
|
+
* Utilities
|
13
|
+
* ----------
|
14
|
+
*/
|
15
|
+
|
16
|
+
const getHeaderOffset = el => {
|
17
|
+
const scrollableContainer = scrollableAncestor(el);
|
18
|
+
const scrollableContainerTop = scrollableContainer ? scrollableContainer.getBoundingClientRect().top : 0;
|
19
|
+
const offsetMeasuringTop = el ? el.getBoundingClientRect().top : 0;
|
20
|
+
const totalHeaderOffset = offsetMeasuringTop !== 0 ? offsetMeasuringTop - scrollableContainerTop : 0;
|
21
|
+
return totalHeaderOffset;
|
22
|
+
};
|
23
|
+
const windowExists = typeof window !== `undefined`;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Determines if the given target is scrollable
|
27
|
+
*
|
28
|
+
* @param {HTMLElement} target
|
29
|
+
* @returns {boolean}
|
30
|
+
*/
|
31
|
+
const scrollable = target => {
|
32
|
+
const style = window.getComputedStyle(target);
|
33
|
+
return /(auto|scroll|hidden)/.test(style.overflow);
|
34
|
+
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Recursively looks for the scrollable ancestor
|
38
|
+
*/
|
39
|
+
const scrollableAncestorInner = target => {
|
40
|
+
if (target.parentNode && target.parentNode !== document) {
|
41
|
+
if (scrollable(target.parentNode)) {
|
42
|
+
return target.parentNode;
|
43
|
+
} else {
|
44
|
+
return scrollableAncestorInner(target.parentNode);
|
45
|
+
}
|
46
|
+
} else {
|
47
|
+
return document.scrollingElement;
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Walks up the parent nodes to identify the first scrollable ancestor
|
53
|
+
*
|
54
|
+
* @param {HTMLElement} target
|
55
|
+
* @returns {HTMLElement}
|
56
|
+
*/
|
57
|
+
const scrollableAncestor = target => {
|
58
|
+
if (!windowExists || !target) {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
|
62
|
+
// based on https://stackoverflow.com/questions/35939886/find-first-scrollable-parent
|
63
|
+
const style = window.getComputedStyle(target);
|
64
|
+
if (!target || !style || style.position === 'fixed') {
|
65
|
+
return document.scrollingElement;
|
66
|
+
}
|
67
|
+
return scrollableAncestorInner(target);
|
68
|
+
};
|
69
|
+
|
70
|
+
exports.getHeaderOffset = getHeaderOffset;
|
71
|
+
exports.scrollableAncestor = scrollableAncestor;
|
@@ -19,6 +19,7 @@ const componentName = 'ProductiveCard';
|
|
19
19
|
exports.ProductiveCard = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
20
20
|
let {
|
21
21
|
actionsPlacement = 'top',
|
22
|
+
children,
|
22
23
|
...rest
|
23
24
|
} = _ref;
|
24
25
|
const validProps = propsHelper.prepareProps(rest, ['media', 'mediaPosition', 'pictogram', 'primaryButtonClick', 'productive', 'secondaryButtonKind']);
|
@@ -26,7 +27,7 @@ exports.ProductiveCard = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
26
27
|
actionsPlacement,
|
27
28
|
ref,
|
28
29
|
productive: true
|
29
|
-
}, devtools.getDevtoolsProps(componentName)));
|
30
|
+
}, devtools.getDevtoolsProps(componentName)), children);
|
30
31
|
});
|
31
32
|
|
32
33
|
// Return a placeholder if not released and not enabled by feature flag
|
@@ -140,8 +140,7 @@ exports.ScrollGradient = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
140
140
|
}, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
|
141
141
|
onScroll: onScroll,
|
142
142
|
ref: setRefs,
|
143
|
-
className: cx(`${blockClass}__content`, scrollElementClassName)
|
144
|
-
tabIndex: 0
|
143
|
+
className: cx(`${blockClass}__content`, scrollElementClassName)
|
145
144
|
}, /*#__PURE__*/React.createElement("span", {
|
146
145
|
ref: intersectionStartRef,
|
147
146
|
"data-start-vertical": true
|
@@ -36,6 +36,10 @@ type SidePanelBaseProps = {
|
|
36
36
|
* Sets the close button icon description
|
37
37
|
*/
|
38
38
|
closeIconDescription?: string;
|
39
|
+
/**
|
40
|
+
* Sets the close button tooltip alignment
|
41
|
+
*/
|
42
|
+
closeIconTooltipAlignment?: string;
|
39
43
|
/**
|
40
44
|
* Determines whether the side panel should render the condensed version (affects action buttons primarily)
|
41
45
|
*/
|
@@ -34,6 +34,7 @@ const componentName = 'SidePanel';
|
|
34
34
|
const defaults = {
|
35
35
|
animateTitle: true,
|
36
36
|
closeIconDescription: 'Close',
|
37
|
+
closeIconTooltipAlignment: 'left',
|
37
38
|
currentStep: 0,
|
38
39
|
hideCloseButton: false,
|
39
40
|
navigationBackIconDescription: 'Back',
|
@@ -53,6 +54,7 @@ const SidePanelBase = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
53
54
|
children,
|
54
55
|
className,
|
55
56
|
closeIconDescription = defaults.closeIconDescription,
|
57
|
+
closeIconTooltipAlignment = defaults.closeIconTooltipAlignment,
|
56
58
|
condensedActions,
|
57
59
|
currentStep = defaults.currentStep,
|
58
60
|
decorator,
|
@@ -467,9 +469,9 @@ const SidePanelBase = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
467
469
|
onClick: onRequestClose,
|
468
470
|
onKeyDown: slideIn ? undefined : handleEscapeKey,
|
469
471
|
ref: closeRef,
|
470
|
-
align:
|
472
|
+
align: closeIconTooltipAlignment
|
471
473
|
}, /*#__PURE__*/React.createElement(icons.Close, {
|
472
|
-
size:
|
474
|
+
size: 16,
|
473
475
|
"aria-hidden": "true",
|
474
476
|
tabIndex: "-1",
|
475
477
|
className: `${blockClass}--btn__icon`
|
@@ -629,6 +631,10 @@ SidePanel.propTypes = {
|
|
629
631
|
* Sets the close button icon description
|
630
632
|
*/
|
631
633
|
closeIconDescription: index.default.string,
|
634
|
+
/**
|
635
|
+
* Sets the close button tooltip alignment
|
636
|
+
*/
|
637
|
+
closeIconTooltipAlignment: index.default.string,
|
632
638
|
/**
|
633
639
|
* Determines whether the side panel should render the condensed version (affects action buttons primarily)
|
634
640
|
*/
|
@@ -260,7 +260,7 @@ const TearsheetShell = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
260
260
|
onKeyDown: keyDownListener,
|
261
261
|
preventCloseOnClickOutside: !isPassive,
|
262
262
|
ref: modalRef,
|
263
|
-
selectorsFloatingMenus: [`.${carbonPrefix}--overflow-menu-options`, `.${carbonPrefix}--tooltip`, '.flatpickr-calendar', `.${bc}__container`, ...selectorsFloatingMenus],
|
263
|
+
selectorsFloatingMenus: [`.${carbonPrefix}--overflow-menu-options`, `.${carbonPrefix}--tooltip`, '.flatpickr-calendar', `.${bc}__container`, `.${carbonPrefix}--menu`, ...selectorsFloatingMenus],
|
264
264
|
size: "sm"
|
265
265
|
}), includeHeader && /*#__PURE__*/React.createElement(react.ModalHeader, {
|
266
266
|
className: cx(`${bc}__header`, {
|
@@ -300,7 +300,8 @@ const TearsheetShell = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
300
300
|
neverRender: influencerPosition === 'right',
|
301
301
|
element: SectionLevel3
|
302
302
|
}, /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
303
|
-
element: react.Layer
|
303
|
+
element: react.Layer,
|
304
|
+
className: `${bc}__layer`
|
304
305
|
}, influencer)), /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
305
306
|
className: `${bc}__right`
|
306
307
|
}, /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
@@ -310,8 +311,9 @@ const TearsheetShell = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
310
311
|
className: `${bc}__content`,
|
311
312
|
alwaysRender: !!(influencer && influencerPosition === 'right'),
|
312
313
|
element: SectionLevel3
|
313
|
-
}, /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
314
|
-
element:
|
314
|
+
}, wide ? children : /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
315
|
+
element: react.Layer,
|
316
|
+
className: `${bc}__layer`
|
315
317
|
}, children)), /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
316
318
|
className: cx({
|
317
319
|
[`${bc}__influencer`]: true,
|
@@ -320,7 +322,8 @@ const TearsheetShell = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
320
322
|
neverRender: influencerPosition !== 'right',
|
321
323
|
element: SectionLevel3
|
322
324
|
}, /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
323
|
-
element: react.Layer
|
325
|
+
element: react.Layer,
|
326
|
+
className: `${bc}__layer`
|
324
327
|
}, influencer))), includeActions && /*#__PURE__*/React.createElement(Wrap.Wrap, {
|
325
328
|
className: `${bc}__button-container`
|
326
329
|
}, /*#__PURE__*/React.createElement(ActionSet.ActionSet, {
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2025
|
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 from 'react';
|
8
|
+
import { PopoverAlignment } from '@carbon/react';
|
9
|
+
interface TruncatedTextProps {
|
10
|
+
/**
|
11
|
+
* Specify how the tooltip should align with the content in tooltip variant. Refer to Carbon tooltip docs for additional information.
|
12
|
+
*/
|
13
|
+
align?: PopoverAlignment;
|
14
|
+
/**
|
15
|
+
* Specify whether a auto align functionality should be applied in tooltip variant. Refer to Carbon tooltip docs for additional information.
|
16
|
+
*/
|
17
|
+
autoAlign?: boolean;
|
18
|
+
/**
|
19
|
+
* Optional class.
|
20
|
+
*/
|
21
|
+
className?: string;
|
22
|
+
/**
|
23
|
+
* The label on the collapse button.
|
24
|
+
*/
|
25
|
+
collapseLabel?: string;
|
26
|
+
/**
|
27
|
+
* The label on expand button.
|
28
|
+
*/
|
29
|
+
expandLabel?: string;
|
30
|
+
/**
|
31
|
+
* Unique identifier for the element.
|
32
|
+
*/
|
33
|
+
id: string;
|
34
|
+
/**
|
35
|
+
* The maximum number of lines to display before truncation.
|
36
|
+
*/
|
37
|
+
lines?: number;
|
38
|
+
/**
|
39
|
+
* The method to display the full text when truncated. Options are "tooltip" or "expand". if not passed, the text would just be truncated with ellipsis.
|
40
|
+
*/
|
41
|
+
type?: 'tooltip' | 'expand';
|
42
|
+
/**
|
43
|
+
* The string value to be truncated.
|
44
|
+
*/
|
45
|
+
value?: string;
|
46
|
+
}
|
47
|
+
export declare let TruncatedText: React.ForwardRefExoticComponent<TruncatedTextProps & React.RefAttributes<HTMLDivElement>>;
|
48
|
+
export {};
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2025
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
11
|
+
var React = require('react');
|
12
|
+
var cx = require('classnames');
|
13
|
+
var react = require('@carbon/react');
|
14
|
+
var settings = require('../../settings.js');
|
15
|
+
var devtools = require('../../global/js/utils/devtools.js');
|
16
|
+
var useTruncatedText = require('./useTruncatedText.js');
|
17
|
+
|
18
|
+
const blockClass = `${settings.pkg.prefix}--truncated-text`;
|
19
|
+
const componentName = 'TruncatedText';
|
20
|
+
exports.TruncatedText = /*#__PURE__*/React.forwardRef((props, ref) => {
|
21
|
+
const {
|
22
|
+
align = 'top',
|
23
|
+
autoAlign = false,
|
24
|
+
className,
|
25
|
+
collapseLabel,
|
26
|
+
expandLabel,
|
27
|
+
id = `${blockClass}-default-id`,
|
28
|
+
lines = 2,
|
29
|
+
value,
|
30
|
+
type = 'tooltip',
|
31
|
+
...rest
|
32
|
+
} = props;
|
33
|
+
const [expanded, setExpanded] = React.useState(false);
|
34
|
+
const {
|
35
|
+
ref: contentRef,
|
36
|
+
truncated
|
37
|
+
} = useTruncatedText.default({
|
38
|
+
lines,
|
39
|
+
value,
|
40
|
+
expanded
|
41
|
+
});
|
42
|
+
const textContentStyles = {
|
43
|
+
WebkitLineClamp: type === 'expand' && !expanded || type === 'tooltip' ? lines : 'none'
|
44
|
+
};
|
45
|
+
const textContentClasses = cx(`${blockClass}__text-content`, {
|
46
|
+
[`${blockClass}__text-content--expanded`]: expanded
|
47
|
+
});
|
48
|
+
const handleExpand = () => {
|
49
|
+
setExpanded(!expanded);
|
50
|
+
};
|
51
|
+
const handleExpandKey = evt => {
|
52
|
+
const {
|
53
|
+
key
|
54
|
+
} = evt;
|
55
|
+
if (key === 'Enter' || key === ' ') {
|
56
|
+
handleExpand();
|
57
|
+
}
|
58
|
+
};
|
59
|
+
const valueBody = /*#__PURE__*/React.createElement("span", {
|
60
|
+
ref: contentRef,
|
61
|
+
className: textContentClasses,
|
62
|
+
id: id,
|
63
|
+
style: textContentStyles
|
64
|
+
}, value);
|
65
|
+
const tooltipVariant = /*#__PURE__*/React.createElement(react.Tooltip, {
|
66
|
+
align: align,
|
67
|
+
autoAlign: autoAlign,
|
68
|
+
label: value
|
69
|
+
}, valueBody);
|
70
|
+
const expandVariant = /*#__PURE__*/React.createElement(React.Fragment, null, valueBody, /*#__PURE__*/React.createElement("span", {
|
71
|
+
"aria-controls": id,
|
72
|
+
"aria-expanded": expanded,
|
73
|
+
className: `${blockClass}__expand-toggle`,
|
74
|
+
onClick: handleExpand,
|
75
|
+
onKeyDown: handleExpandKey,
|
76
|
+
role: "button",
|
77
|
+
tabIndex: 0
|
78
|
+
}, expanded ? collapseLabel : expandLabel));
|
79
|
+
const truncatedBody = type === 'expand' ? expandVariant : tooltipVariant;
|
80
|
+
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
81
|
+
className: cx(blockClass, className),
|
82
|
+
ref: ref
|
83
|
+
}, devtools.getDevtoolsProps(componentName)), truncated ? truncatedBody : valueBody);
|
84
|
+
});
|
85
|
+
exports.TruncatedText = settings.pkg.checkComponentEnabled(exports.TruncatedText, componentName);
|
86
|
+
exports.TruncatedText.displayName = componentName;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2025
|
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
|
+
interface Params {
|
8
|
+
lines?: number;
|
9
|
+
value?: string;
|
10
|
+
expanded?: boolean;
|
11
|
+
}
|
12
|
+
export default function useTruncatedText({ lines, value, expanded }: Params): {
|
13
|
+
ref: import("react").RefObject<HTMLElement | null>;
|
14
|
+
truncated: boolean;
|
15
|
+
};
|
16
|
+
export {};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2025
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
11
|
+
|
12
|
+
var React = require('react');
|
13
|
+
var checkForOverflow = require('../../global/js/utils/checkForOverflow.js');
|
14
|
+
|
15
|
+
function useTruncatedText(_ref) {
|
16
|
+
let {
|
17
|
+
lines,
|
18
|
+
value,
|
19
|
+
expanded
|
20
|
+
} = _ref;
|
21
|
+
const [truncated, setTruncated] = React.useState(false);
|
22
|
+
const ref = React.useRef(null);
|
23
|
+
React.useEffect(() => {
|
24
|
+
const resizeObserver = new ResizeObserver(() => {
|
25
|
+
if (!expanded) {
|
26
|
+
const result = checkForOverflow.checkHeightOverflow(ref.current);
|
27
|
+
if (result !== truncated) {
|
28
|
+
setTruncated(result);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
});
|
32
|
+
if (ref.current) {
|
33
|
+
resizeObserver.observe(ref.current);
|
34
|
+
}
|
35
|
+
return () => {
|
36
|
+
resizeObserver.disconnect();
|
37
|
+
};
|
38
|
+
}, [expanded, lines, value, truncated]);
|
39
|
+
return {
|
40
|
+
ref,
|
41
|
+
truncated
|
42
|
+
};
|
43
|
+
}
|
44
|
+
|
45
|
+
exports.default = useTruncatedText;
|
@@ -38,6 +38,7 @@ export * from './EditFullPage';
|
|
38
38
|
export * from './EditUpdateCards';
|
39
39
|
export * from './Checklist';
|
40
40
|
export { Coachmark } from './Coachmark';
|
41
|
+
export { Coachmark as preview__Coachmark } from './Coachmark/next/Coachmark';
|
41
42
|
export * from './CoachmarkBeacon';
|
42
43
|
export * from './CoachmarkButton';
|
43
44
|
export * from './CoachmarkFixed';
|
@@ -47,8 +48,9 @@ export * from './CoachmarkStack';
|
|
47
48
|
export * from './Guidebanner';
|
48
49
|
export * from './InlineTip';
|
49
50
|
export * from './NonLinearReading';
|
50
|
-
export * from './
|
51
|
+
export * from './BigNumber';
|
51
52
|
export * from './TruncatedList';
|
53
|
+
export * from './TruncatedText';
|
52
54
|
export * from './InterstitialScreen';
|
53
55
|
export * from './DelimitedList';
|
54
56
|
export * from './Decorator';
|
@@ -68,5 +70,5 @@ export { ActionBar } from './ActionBar';
|
|
68
70
|
export * from './FilterPanel';
|
69
71
|
export * from './ConditionBuilder';
|
70
72
|
export * from './GetStartedCard';
|
71
|
-
export * as
|
73
|
+
export * as preview__PageHeader from './PageHeader/next/PageHeader';
|
72
74
|
export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags, } from './FeatureFlags';
|
@@ -5,5 +5,5 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
import { RefObject } from 'react';
|
8
|
-
export declare function useOverflowStringWidth(elementRef: RefObject<HTMLElement>): boolean | undefined;
|
9
|
-
export declare const useOverflowStringHeight: (elementRef: RefObject<HTMLElement>) => boolean | undefined;
|
8
|
+
export declare function useOverflowStringWidth(elementRef: RefObject<HTMLElement | null>): boolean | undefined;
|
9
|
+
export declare const useOverflowStringHeight: (elementRef: RefObject<HTMLElement | null>) => boolean | undefined;
|
@@ -10,7 +10,7 @@
|
|
10
10
|
require('../../../feature-flags.js');
|
11
11
|
var React = require('react');
|
12
12
|
var settings = require('../../../settings.js');
|
13
|
-
var
|
13
|
+
var ReactDOM = require('react-dom');
|
14
14
|
var index = require('../../../components/FeatureFlags/index.js');
|
15
15
|
|
16
16
|
const usePortalTarget = portalTargetIn => {
|
@@ -25,7 +25,7 @@ const usePortalTarget = portalTargetIn => {
|
|
25
25
|
}
|
26
26
|
}
|
27
27
|
}, [portalTargetIn, enablePortalTarget]);
|
28
|
-
const renderPortalUse = React.useCallback(children => portalTarget ? /*#__PURE__*/
|
28
|
+
const renderPortalUse = React.useCallback(children => portalTarget ? /*#__PURE__*/ReactDOM.createPortal(children, portalTarget) : children, [portalTarget]);
|
29
29
|
return renderPortalUse;
|
30
30
|
};
|
31
31
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
import { RefObject } from 'react';
|
8
|
-
export declare const useResizeObserver: (ref: RefObject<HTMLElement>, onResize?: (rect: DOMRectReadOnly) => void) => {
|
8
|
+
export declare const useResizeObserver: (ref: RefObject<HTMLElement | null>, onResize?: (rect: DOMRectReadOnly) => void) => {
|
9
9
|
width: number;
|
10
10
|
height: number;
|
11
11
|
};
|
@@ -81,8 +81,9 @@ declare namespace defaults {
|
|
81
81
|
let Nav: boolean;
|
82
82
|
let NavItem: boolean;
|
83
83
|
let NavList: boolean;
|
84
|
-
let
|
84
|
+
let BigNumber: boolean;
|
85
85
|
let TruncatedList: boolean;
|
86
|
+
let TruncatedText: boolean;
|
86
87
|
let DelimitedList: boolean;
|
87
88
|
let ScrollGradient: boolean;
|
88
89
|
let StringFormatter: boolean;
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
11
11
|
|
12
|
-
// Copyright IBM Corp. 2020,
|
12
|
+
// Copyright IBM Corp. 2020, 2025
|
13
13
|
//
|
14
14
|
// This source code is licensed under the Apache-2.0 license found in the
|
15
15
|
// LICENSE file in the root directory of this source tree.
|
@@ -81,8 +81,9 @@ const defaults = {
|
|
81
81
|
Nav: false,
|
82
82
|
NavItem: false,
|
83
83
|
NavList: false,
|
84
|
-
|
84
|
+
BigNumber: false,
|
85
85
|
TruncatedList: false,
|
86
|
+
TruncatedText: false,
|
86
87
|
DelimitedList: false,
|
87
88
|
ScrollGradient: false,
|
88
89
|
StringFormatter: false,
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2025
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
// Copyright IBM Corp. 2024, 2024
|
11
|
+
//
|
12
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
13
|
+
// LICENSE file in the root directory of this source tree.
|
14
|
+
//
|
15
|
+
|
16
|
+
const checkHeightOverflow = el => {
|
17
|
+
if (el) {
|
18
|
+
return el?.offsetHeight < el?.scrollHeight;
|
19
|
+
}
|
20
|
+
return false;
|
21
|
+
};
|
22
|
+
|
23
|
+
exports.checkHeightOverflow = checkHeightOverflow;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { makeDraggable } from "./makeDraggable";
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2025, 2025
|
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
|
+
interface DraggableProps {
|
8
|
+
el: HTMLElement;
|
9
|
+
dragHandle?: HTMLElement;
|
10
|
+
focusableDragHandle?: HTMLElement;
|
11
|
+
dragStep?: number;
|
12
|
+
shiftDragStep?: number;
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Makes a given element draggable using a handle element.
|
16
|
+
*@param draggable - object which accepts el and optional attributes handle,focusableInHandle,dragStep and shiftDragStep
|
17
|
+
*/
|
18
|
+
export declare function makeDraggable({ el, dragHandle, focusableDragHandle, dragStep, shiftDragStep, }: DraggableProps): void;
|
19
|
+
export {};
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2025
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Makes a given element draggable using a handle element.
|
12
|
+
*@param draggable - object which accepts el and optional attributes handle,focusableInHandle,dragStep and shiftDragStep
|
13
|
+
*/
|
14
|
+
|
15
|
+
function makeDraggable(_ref) {
|
16
|
+
let {
|
17
|
+
el,
|
18
|
+
dragHandle,
|
19
|
+
focusableDragHandle,
|
20
|
+
dragStep,
|
21
|
+
shiftDragStep
|
22
|
+
} = _ref;
|
23
|
+
const computedStyle = window.getComputedStyle(el);
|
24
|
+
if (dragHandle) {
|
25
|
+
dragHandle.style.cursor = 'move';
|
26
|
+
el.style.cursor = 'default';
|
27
|
+
} else {
|
28
|
+
el.style.cursor = 'move';
|
29
|
+
}
|
30
|
+
const position = computedStyle.position;
|
31
|
+
if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') {
|
32
|
+
el.style.position = 'relative';
|
33
|
+
}
|
34
|
+
let isDragging = false;
|
35
|
+
let offsetX = 0;
|
36
|
+
let offsetY = 0;
|
37
|
+
function onKeyDown(e) {
|
38
|
+
const distance = e.shiftKey ? shiftDragStep ?? 32 : dragStep ?? 8;
|
39
|
+
switch (e.key) {
|
40
|
+
case 'Enter':
|
41
|
+
case ' ':
|
42
|
+
e.preventDefault();
|
43
|
+
break;
|
44
|
+
case 'ArrowLeft':
|
45
|
+
el.style.left = `${el.offsetLeft - distance}px`;
|
46
|
+
break;
|
47
|
+
case 'ArrowRight':
|
48
|
+
el.style.left = `${el.offsetLeft + distance}px`;
|
49
|
+
break;
|
50
|
+
case 'ArrowUp':
|
51
|
+
el.style.top = `${el.offsetTop - distance}px`;
|
52
|
+
break;
|
53
|
+
case 'ArrowDown':
|
54
|
+
el.style.top = `${el.offsetTop + distance}px`;
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
function onMouseDown(e) {
|
59
|
+
const isTargetInHandle = dragHandle ? dragHandle.contains(e.target) : el.contains(e.target);
|
60
|
+
if (!isTargetInHandle) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
offsetX = e.clientX - el.offsetLeft;
|
64
|
+
offsetY = e.clientY - el.offsetTop;
|
65
|
+
isDragging = true;
|
66
|
+
document.addEventListener('mousemove', onMouseMove);
|
67
|
+
document.addEventListener('mouseup', onMouseUp, {
|
68
|
+
once: true
|
69
|
+
});
|
70
|
+
}
|
71
|
+
function onMouseMove(e) {
|
72
|
+
if (!isDragging) {
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
el.style.left = `${e.clientX - offsetX}px`;
|
76
|
+
el.style.top = `${e.clientY - offsetY}px`;
|
77
|
+
}
|
78
|
+
function onMouseUp() {
|
79
|
+
if (!isDragging) {
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
isDragging = false;
|
83
|
+
document.removeEventListener('mousemove', onMouseMove);
|
84
|
+
}
|
85
|
+
if (dragHandle) {
|
86
|
+
dragHandle.addEventListener('mousedown', onMouseDown);
|
87
|
+
} else {
|
88
|
+
el.addEventListener('mousedown', onMouseDown);
|
89
|
+
}
|
90
|
+
focusableDragHandle?.addEventListener('keydown', onKeyDown);
|
91
|
+
}
|
92
|
+
|
93
|
+
exports.makeDraggable = makeDraggable;
|