@coinbase/cds-mobile 8.45.0 → 8.46.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/CHANGELOG.md +6 -0
- package/dts/overlays/tooltip/Tooltip.d.ts +2 -0
- package/dts/overlays/tooltip/Tooltip.d.ts.map +1 -1
- package/dts/overlays/tooltip/TooltipProps.d.ts +8 -0
- package/dts/overlays/tooltip/TooltipProps.d.ts.map +1 -1
- package/esm/overlays/__stories__/TooltipV2.stories.js +61 -9
- package/esm/overlays/tooltip/Tooltip.js +50 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 8.46.0 (2/12/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🚀 Updates
|
|
14
|
+
|
|
15
|
+
- Add open/close visibility delays to Tooltip. [[#234](https://github.com/coinbase/cds/pull/234)]
|
|
16
|
+
|
|
11
17
|
## 8.45.0 (2/12/2026 PST)
|
|
12
18
|
|
|
13
19
|
#### 🚀 Updates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/overlays/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/overlays/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AAMjG,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,OAAO,qSAmBf,YAAY,6CAsJhB,CAAC"}
|
|
@@ -25,6 +25,14 @@ export type TooltipBaseProps = SharedProps &
|
|
|
25
25
|
* @default true
|
|
26
26
|
*/
|
|
27
27
|
visible?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Delay (in ms) before showing the tooltip after press.
|
|
30
|
+
*/
|
|
31
|
+
openDelay?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Delay (in ms) before hiding the tooltip after dismiss.
|
|
34
|
+
*/
|
|
35
|
+
closeDelay?: number;
|
|
28
36
|
/** Invert the theme's activeColorScheme for this component
|
|
29
37
|
* @default true
|
|
30
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipProps.d.ts","sourceRoot":"","sources":["../../../src/overlays/tooltip/TooltipProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,EAAE,QAAQ,GAAG,KAAK,CAAC,CAAC;AAE/E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GACxC,cAAc,GAAG;IACf,sDAAsD;IACtD,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B,gDAAgD;IAChD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;;;OAIG;IACH,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iIAAiI;IACjI,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;I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CAAC;IAC5E;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC,mBAAmB,CAAC,CAAC;CACnE,CAAC;AAEJ,MAAM,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAE5C,kEAAkE;AAClE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GACzD,IAAI,CACF,YAAY,EACV,SAAS,GACT,WAAW,GACX,KAAK,GACL,QAAQ,GACR,yBAAyB,GACzB,mBAAmB,GACnB,WAAW,CACd,GAAG;IACF,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IACvC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC;IAC3B,qBAAqB,CAAC,EAAE,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAC3D,kBAAkB,CAAC,EAAE,SAAS,CAAC,oBAAoB,CAAC,CAAC;CACtD,CAAC;AAEJ,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IACzC,aAAa,EAAE,eAAe,CAAC;CAChC,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,yBAAyB,CAAC,CAAC"}
|
|
@@ -14,6 +14,55 @@ const bottomTextSubject = 'BOTTOM';
|
|
|
14
14
|
const customTextSubject = 'CUSTOM';
|
|
15
15
|
const shortText = 'This is the short text.';
|
|
16
16
|
const longText = 'This is the really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long text.';
|
|
17
|
+
const DelayVariations = () => {
|
|
18
|
+
return /*#__PURE__*/_jsx(Example, {
|
|
19
|
+
title: "Delay Variations",
|
|
20
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
21
|
+
background: "bgAlternate",
|
|
22
|
+
gap: 4,
|
|
23
|
+
paddingY: 2,
|
|
24
|
+
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
25
|
+
justifyContent: "space-evenly",
|
|
26
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
27
|
+
closeDelay: 0,
|
|
28
|
+
content: "Opens after 400ms",
|
|
29
|
+
openDelay: 400,
|
|
30
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
31
|
+
font: "label2",
|
|
32
|
+
children: "Open delay 400ms"
|
|
33
|
+
})
|
|
34
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
35
|
+
closeDelay: 200,
|
|
36
|
+
content: "Closes after 200ms",
|
|
37
|
+
openDelay: 0,
|
|
38
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
39
|
+
font: "label2",
|
|
40
|
+
children: "Close delay 200ms"
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
}), /*#__PURE__*/_jsxs(HStack, {
|
|
44
|
+
justifyContent: "space-evenly",
|
|
45
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
46
|
+
closeDelay: 150,
|
|
47
|
+
content: "Open 300 / Close 150",
|
|
48
|
+
openDelay: 300,
|
|
49
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
50
|
+
font: "label2",
|
|
51
|
+
children: "Open 300 / Close 150"
|
|
52
|
+
})
|
|
53
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
54
|
+
closeDelay: 300,
|
|
55
|
+
content: "Open 500 / Close 300",
|
|
56
|
+
openDelay: 500,
|
|
57
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
58
|
+
font: "label2",
|
|
59
|
+
children: "Open 500 / Close 300"
|
|
60
|
+
})
|
|
61
|
+
})]
|
|
62
|
+
})]
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
17
66
|
const ToolTipWithA11y = _ref => {
|
|
18
67
|
let {
|
|
19
68
|
tooltipText,
|
|
@@ -226,7 +275,7 @@ const RNModalTest = () => {
|
|
|
226
275
|
const [yShiftByStatusBarHeight, setYShiftByStatusBarHeight] = useState(true);
|
|
227
276
|
const toggleOnShiftMeasurementByStatusBar = useCallback(() => setYShiftByStatusBarHeight(true), []);
|
|
228
277
|
const toggleOffShiftMeasurementByStatusBar = useCallback(() => setYShiftByStatusBarHeight(false), []);
|
|
229
|
-
return /*#__PURE__*/_jsxs(
|
|
278
|
+
return /*#__PURE__*/_jsxs(Example, {
|
|
230
279
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
231
280
|
onPress: setVisibleToOn,
|
|
232
281
|
children: "Open RN Modal Test 2"
|
|
@@ -284,14 +333,17 @@ const DisabledTest = () => {
|
|
|
284
333
|
});
|
|
285
334
|
};
|
|
286
335
|
const TooltipV2Screen = () => {
|
|
287
|
-
return /*#__PURE__*/
|
|
288
|
-
children:
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
336
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
337
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
338
|
+
gap: 2,
|
|
339
|
+
children: [/*#__PURE__*/_jsx(CDSModalTest, {}), /*#__PURE__*/_jsx(RNModalTest, {}), /*#__PURE__*/_jsx(DelayVariations, {}), /*#__PURE__*/_jsx(Content, {
|
|
340
|
+
title: "Short Text Tooltip",
|
|
341
|
+
tooltipText: shortText
|
|
342
|
+
}), /*#__PURE__*/_jsx(Content, {
|
|
343
|
+
title: "Long Text Tooltip",
|
|
344
|
+
tooltipText: longText
|
|
345
|
+
}), /*#__PURE__*/_jsx(DisabledTest, {})]
|
|
346
|
+
})
|
|
295
347
|
});
|
|
296
348
|
};
|
|
297
349
|
export default TooltipV2Screen;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { Fragment, memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import React, { Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Modal as RNModal, TouchableOpacity, View } from 'react-native';
|
|
4
4
|
import { InvertedThemeProvider } from '../../system/ThemeProvider';
|
|
5
5
|
import { InternalTooltip } from './InternalTooltip';
|
|
@@ -21,12 +21,16 @@ export const Tooltip = /*#__PURE__*/memo(_ref => {
|
|
|
21
21
|
accessibilityHintForContent,
|
|
22
22
|
visible,
|
|
23
23
|
invertColorScheme = true,
|
|
24
|
-
elevation
|
|
24
|
+
elevation,
|
|
25
|
+
openDelay,
|
|
26
|
+
closeDelay
|
|
25
27
|
} = _ref;
|
|
26
28
|
const subjectRef = useRef(null);
|
|
27
29
|
const [isOpen, setIsOpen] = useState(false);
|
|
28
30
|
const isVisible = visible !== false && isOpen;
|
|
29
31
|
const [subjectLayout, setSubjectLayout] = useState();
|
|
32
|
+
const openTimeoutRef = useRef(null);
|
|
33
|
+
const closeTimeoutRef = useRef(null);
|
|
30
34
|
const WrapperComponent = invertColorScheme ? InvertedThemeProvider : Fragment;
|
|
31
35
|
const {
|
|
32
36
|
opacity,
|
|
@@ -34,14 +38,36 @@ export const Tooltip = /*#__PURE__*/memo(_ref => {
|
|
|
34
38
|
animateIn,
|
|
35
39
|
animateOut
|
|
36
40
|
} = useTooltipAnimation(placement);
|
|
41
|
+
const clearOpenTimeout = useCallback(() => {
|
|
42
|
+
if (openTimeoutRef.current) {
|
|
43
|
+
clearTimeout(openTimeoutRef.current);
|
|
44
|
+
openTimeoutRef.current = null;
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
47
|
+
const clearCloseTimeout = useCallback(() => {
|
|
48
|
+
if (closeTimeoutRef.current) {
|
|
49
|
+
clearTimeout(closeTimeoutRef.current);
|
|
50
|
+
closeTimeoutRef.current = null;
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
37
53
|
const handleRequestClose = useCallback(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
clearOpenTimeout();
|
|
55
|
+
clearCloseTimeout();
|
|
56
|
+
const closeTooltip = () => {
|
|
57
|
+
animateOut.start(() => {
|
|
58
|
+
setIsOpen(false);
|
|
59
|
+
onCloseTooltip == null || onCloseTooltip();
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
if (closeDelay && closeDelay > 0) {
|
|
63
|
+
closeTimeoutRef.current = setTimeout(closeTooltip, closeDelay);
|
|
64
|
+
} else {
|
|
65
|
+
closeTooltip();
|
|
66
|
+
}
|
|
67
|
+
}, [animateOut, clearCloseTimeout, clearOpenTimeout, closeDelay, onCloseTooltip]);
|
|
43
68
|
const handlePressSubject = useCallback(() => {
|
|
44
69
|
var _subjectRef$current;
|
|
70
|
+
clearCloseTimeout();
|
|
45
71
|
(_subjectRef$current = subjectRef.current) == null || _subjectRef$current.measure((x, y, width, height, pageOffsetX, pageOffsetY) => {
|
|
46
72
|
setSubjectLayout({
|
|
47
73
|
width,
|
|
@@ -50,9 +76,17 @@ export const Tooltip = /*#__PURE__*/memo(_ref => {
|
|
|
50
76
|
pageOffsetY
|
|
51
77
|
});
|
|
52
78
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
79
|
+
const openTooltip = () => {
|
|
80
|
+
setIsOpen(true);
|
|
81
|
+
onOpenTooltip == null || onOpenTooltip();
|
|
82
|
+
};
|
|
83
|
+
clearOpenTimeout();
|
|
84
|
+
if (openDelay && openDelay > 0) {
|
|
85
|
+
openTimeoutRef.current = setTimeout(openTooltip, openDelay);
|
|
86
|
+
} else {
|
|
87
|
+
openTooltip();
|
|
88
|
+
}
|
|
89
|
+
}, [clearCloseTimeout, clearOpenTimeout, onOpenTooltip, openDelay]);
|
|
56
90
|
|
|
57
91
|
// The accessibility props for the trigger component. Trigger component
|
|
58
92
|
// equals the component where when you click on it, it will show the tooltip
|
|
@@ -66,6 +100,12 @@ export const Tooltip = /*#__PURE__*/memo(_ref => {
|
|
|
66
100
|
onAccessibilityEscape: handleRequestClose,
|
|
67
101
|
onAccessibilityTap: handleRequestClose
|
|
68
102
|
}), [content, accessibilityLabelForContent, accessibilityHintForContent, handleRequestClose]);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
return () => {
|
|
105
|
+
clearOpenTimeout();
|
|
106
|
+
clearCloseTimeout();
|
|
107
|
+
};
|
|
108
|
+
}, [clearCloseTimeout, clearOpenTimeout]);
|
|
69
109
|
return /*#__PURE__*/_jsxs(View, {
|
|
70
110
|
ref: subjectRef,
|
|
71
111
|
collapsable: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.46.0",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"react-native-svg": "^14.1.0"
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
|
-
"@coinbase/cds-common": "^8.
|
|
201
|
+
"@coinbase/cds-common": "^8.46.0",
|
|
202
202
|
"@coinbase/cds-icons": "^5.11.0",
|
|
203
203
|
"@coinbase/cds-illustrations": "^4.31.0",
|
|
204
204
|
"@coinbase/cds-lottie-files": "^3.3.4",
|