@spaced-out/ui-design-system 0.6.33 → 0.6.34
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 +7 -0
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.d.ts.map +1 -1
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.js +66 -53
- package/lib/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.module.css +0 -3
- package/mcp/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.6.34](https://github.com/spaced-out/ui-design-system/compare/v0.6.33...v0.6.34) (2026-09-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* truncated text with tooltip issues ([#507](https://github.com/spaced-out/ui-design-system/issues/507)) ([8dd98b9](https://github.com/spaced-out/ui-design-system/commit/8dd98b903010b1fccf2e42cd3d370c56a5ab21be))
|
|
11
|
+
|
|
5
12
|
### [0.6.33](https://github.com/spaced-out/ui-design-system/compare/v0.6.32...v0.6.33) (2026-09-15)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TruncatedTextWithTooltip.d.ts","sourceRoot":"","sources":["../../../src/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TruncatedTextWithTooltip.d.ts","sourceRoot":"","sources":["../../../src/components/TruncatedTextWithTooltip/TruncatedTextWithTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAM7D,KAAK,UAAU,GAAG,QAAQ,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,wBAAwB,GAAI,uEAQtC,6BAA6B,sBAiH/B,CAAC"}
|
|
@@ -8,16 +8,11 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
10
|
var _qa = require("../../utils/qa");
|
|
11
|
-
var _ConditionalWrapper = require("../ConditionalWrapper");
|
|
12
11
|
var _Tooltip = require("../Tooltip");
|
|
13
12
|
var _TruncatedTextWithTooltipModule = _interopRequireDefault(require("./TruncatedTextWithTooltip.module.css"));
|
|
14
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
|
-
// Define the expected props for the child element that can be cloned
|
|
18
|
-
|
|
19
|
-
// Type for a child element that can be cloned
|
|
20
|
-
|
|
21
16
|
const TruncatedTextWithTooltip = _ref => {
|
|
22
17
|
let {
|
|
23
18
|
classNames,
|
|
@@ -41,6 +36,15 @@ const TruncatedTextWithTooltip = _ref => {
|
|
|
41
36
|
}), [truncatedNode, wrapText]);
|
|
42
37
|
React.useEffect(() => {
|
|
43
38
|
checkIfTextOverflowing();
|
|
39
|
+
// Cancel the outgoing debounce instance's pending trailing-edge call.
|
|
40
|
+
// checkIfTextOverflowing is recreated whenever truncatedNode changes
|
|
41
|
+
// (e.g. once on mount, null -> real node). Without this cancel, the
|
|
42
|
+
// stale instance's trailing call still fires ~200ms later using its
|
|
43
|
+
// frozen closure (truncatedNode as it was when THAT instance was
|
|
44
|
+
// created) and can stomp a correct value the new instance already set.
|
|
45
|
+
return () => {
|
|
46
|
+
checkIfTextOverflowing.cancel();
|
|
47
|
+
};
|
|
44
48
|
}, [line, children, wrapText, checkIfTextOverflowing]);
|
|
45
49
|
React.useEffect(() => {
|
|
46
50
|
if (!truncatedNode) {
|
|
@@ -58,57 +62,66 @@ const TruncatedTextWithTooltip = _ref => {
|
|
|
58
62
|
'--line-clamp': wrapText ? 'unset' : line,
|
|
59
63
|
'--word-break': wordBreak
|
|
60
64
|
};
|
|
61
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConditionalWrapper.ConditionalWrapper, {
|
|
62
|
-
condition: Boolean(showMouseTip),
|
|
63
|
-
wrapper: children => {
|
|
64
|
-
const child = React.Children.only(children);
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
// Always render the same <span>, always wrapped in the same <Tooltip>,
|
|
67
|
+
// toggling only Tooltip's `hidden` prop. Previously a ConditionalWrapper
|
|
68
|
+
// swapped between a bare <span> and <Tooltip><div>{span}</div></Tooltip>
|
|
69
|
+
// based on showMouseTip — changing the element type at this tree position
|
|
70
|
+
// forces React to unmount/remount the span every time showMouseTip
|
|
71
|
+
// toggles. The remounted span (now a flex child of an extra wrapper div)
|
|
72
|
+
// measures different scrollHeight/clientHeight than the bare span, so the
|
|
73
|
+
// ResizeObserver above sees its own self-inflicted resize and flips
|
|
74
|
+
// showMouseTip again — an infinite loop where the tooltip never
|
|
75
|
+
// stabilizes. Tooltip clones its trigger prop onto the same element (no
|
|
76
|
+
// wrapper element inserted), so keeping the span's identity stable here
|
|
77
|
+
// means toggling showMouseTip no longer causes a remount.
|
|
78
|
+
const truncatedSpan = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
79
|
+
className: (0, _classify.default)(_TruncatedTextWithTooltipModule.default.truncateLineClamp, classNames?.wrapper),
|
|
80
|
+
style: styles,
|
|
81
|
+
ref: setTruncatedNode,
|
|
82
|
+
"data-testid": (0, _qa.generateTestId)({
|
|
83
|
+
base: testId,
|
|
84
|
+
slot: 'text'
|
|
85
|
+
}),
|
|
86
|
+
children: children
|
|
87
|
+
});
|
|
74
88
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
103
|
-
className: (0, _classify.default)(_TruncatedTextWithTooltipModule.default.truncateLineClamp, classNames?.wrapper),
|
|
104
|
-
style: styles,
|
|
105
|
-
ref: setTruncatedNode,
|
|
106
|
-
"data-testid": (0, _qa.generateTestId)({
|
|
107
|
-
base: testId,
|
|
108
|
-
slot: 'text'
|
|
109
|
-
}),
|
|
110
|
-
children: children
|
|
89
|
+
// `ref: null` is required here: React.cloneElement inherits the source
|
|
90
|
+
// element's ref unless explicitly overridden. Without this, this
|
|
91
|
+
// body-only clone (rendered separately inside Tooltip's floating panel,
|
|
92
|
+
// gated by `hidden`) would share the trigger span's ref. Mounting/
|
|
93
|
+
// unmounting this clone as `hidden` toggles would hijack truncatedNode
|
|
94
|
+
// away from the actual trigger, eventually losing the ref to the real
|
|
95
|
+
// trigger permanently once this clone unmounts.
|
|
96
|
+
//
|
|
97
|
+
// No className/style here (rather than trying to override --line-clamp):
|
|
98
|
+
// Tooltip already wraps body in <Truncate line={bodyMaxLines}>, which puts
|
|
99
|
+
// its own webkit-box line-clamp on the containing div. Keeping
|
|
100
|
+
// css.truncateLineClamp on this span would make it a second, nested
|
|
101
|
+
// webkit-box with its own --word-break (this component's `wordBreak` prop,
|
|
102
|
+
// meant for the single-line trigger) — since that inner box is what
|
|
103
|
+
// actually renders the text, it silently wins over the outer div's
|
|
104
|
+
// word-break even when both clamp to the same line count. Dropping the
|
|
105
|
+
// class/style lets the outer div be the only clamp in the chain.
|
|
106
|
+
const modifiedChild = /*#__PURE__*/React.cloneElement(truncatedSpan, {
|
|
107
|
+
ref: null,
|
|
108
|
+
className: undefined,
|
|
109
|
+
style: undefined,
|
|
110
|
+
'data-testid': (0, _qa.generateTestId)({
|
|
111
|
+
base: testId,
|
|
112
|
+
slot: 'body-text'
|
|
111
113
|
})
|
|
112
114
|
});
|
|
115
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.Tooltip, {
|
|
116
|
+
...tooltip,
|
|
117
|
+
hidden: tooltip?.hidden ?? !showMouseTip,
|
|
118
|
+
body: tooltip?.body || modifiedChild,
|
|
119
|
+
elevation: tooltip?.elevation ?? 'toast',
|
|
120
|
+
testId: (0, _qa.generateTestId)({
|
|
121
|
+
base: testId,
|
|
122
|
+
slot: 'tooltip'
|
|
123
|
+
}),
|
|
124
|
+
children: truncatedSpan
|
|
125
|
+
});
|
|
113
126
|
};
|
|
114
127
|
exports.TruncatedTextWithTooltip = TruncatedTextWithTooltip;
|
package/mcp/package.json
CHANGED