@semcore/ellipsis 16.0.12 → 17.0.0-prerelease.18

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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [17.0.0] - 2026-02-18
6
+
7
+ ### BREAK
8
+
9
+ - Deprecated component. Use the new `ellipsis` prop that's built into various components.
10
+
5
11
  ## [16.0.12] - 2025-11-14
6
12
 
7
13
  ### Changed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![version](https://img.shields.io/npm/v/@semcore/ellipsis.svg)](https://www.npmjs.com/@semcore/ellipsis)
4
4
  [![downloads](https://img.shields.io/npm/dt/@semcore/ellipsis.svg)](https://www.npmjs.com/package/@semcore/ellipsis)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/semrush/intergalactic/blob/master/LICENSE)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE)
6
6
 
7
7
  > This component is part of the Intergalactic Design System
8
8
 
@@ -20,13 +20,13 @@ npm install @semcore/ellipsis
20
20
 
21
21
  ## 👤 Author
22
22
 
23
- [UI-kit team](https://github.com/semrush/intergalactic/blob/master/MAINTAINERS) and [other ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
23
+ [UI-kit team](https://github.com/semrush/intergalactic/blob/HEAD/MAINTAINERS) and [other ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
24
24
 
25
25
  ## 🤝 Contributing
26
26
 
27
27
  Contributions, issues and feature requests are welcome!
28
28
 
29
- Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/master/CONTRIBUTING.md).
29
+ Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/HEAD/CONTRIBUTING.md).
30
30
 
31
31
  ## Show your support
32
32
 
@@ -34,4 +34,4 @@ Give a ⭐️ if this project helped you!
34
34
 
35
35
  ## 📝 License
36
36
 
37
- This project is [MIT](https://github.com/semrush/intergalactic/blob/master/LICENSE) licensed.
37
+ This project is [MIT](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE) licensed.
@@ -1,289 +1,237 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
15
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
8
+ exports.default = void 0;
16
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
10
  var _core = require("@semcore/core");
11
+ var _baseComponents = require("@semcore/base-components");
18
12
  var _assignProps3 = require("@semcore/core/lib/utils/assignProps");
19
13
  var _findComponent = _interopRequireWildcard(require("@semcore/core/lib/utils/findComponent"));
20
14
  var _getOriginChildren = _interopRequireDefault(require("@semcore/core/lib/utils/getOriginChildren"));
21
15
  var _pick = _interopRequireDefault(require("@semcore/core/lib/utils/pick"));
22
16
  var _reactToText = _interopRequireDefault(require("@semcore/core/lib/utils/reactToText"));
23
- var _ref9 = require("@semcore/core/lib/utils/ref");
17
+ var _ref8 = require("@semcore/core/lib/utils/ref");
24
18
  var _useEnhancedEffect = _interopRequireDefault(require("@semcore/core/lib/utils/use/useEnhancedEffect"));
25
- var _flexBox = require("@semcore/flex-box");
26
19
  var _tooltip = _interopRequireDefault(require("@semcore/tooltip"));
27
20
  var _react = _interopRequireDefault(require("react"));
28
21
  var _useResizeObserver = require("./useResizeObserver");
29
- var _excluded = ["styles", "Children", "maxLine", "tooltip", "trim", "containerRect", "containerRef", "includeTooltipProps", "children"];
22
+ var _utils = require("./utils");
30
23
  /*!__reshadow-styles__:"./style/ellipsis.shadow.css"*/
31
- var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBeginning_4aonj_gg_,.___SEllipsis_4aonj_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SEllipsis_4aonj_gg_.__maxLine_4aonj_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_4aonj);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SContainerMiddle_4aonj_gg_,.___SContainer_4aonj_gg_,.___SEllipsis_4aonj_gg_.__middle-mod_4aonj_gg_,.___SNoTooltipContainer_4aonj_gg_{display:flex;overflow:hidden}.___SContainerMiddle_4aonj_gg_>:has(.___SBeginning_4aonj_gg_),.___SContainerMiddle_4aonj_gg_>:has(.___STail_4aonj_gg_){display:flex;width:100%}.___STail_4aonj_gg_{white-space:pre}", /*__inner_css_end__*/"4aonj_gg_"),
24
+ const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBeginning_1x34o_gg_,.___SEllipsis_1x34o_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SEllipsis_1x34o_gg_.__maxLine_1x34o_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_1x34o);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SContainerMiddle_1x34o_gg_,.___SContainer_1x34o_gg_,.___SEllipsis_1x34o_gg_.__middle-mod_1x34o_gg_,.___SNoTooltipContainer_1x34o_gg_{display:flex;overflow:hidden}.___SContainerMiddle_1x34o_gg_>:has(.___SBeginning_1x34o_gg_),.___SContainerMiddle_1x34o_gg_>:has(.___STail_1x34o_gg_){display:flex;width:100%}.___STail_1x34o_gg_{white-space:pre}", /*__inner_css_end__*/"1x34o_gg_"),
32
25
  /*__reshadow_css_end__*/
33
26
  {
34
- "__SBeginning": "___SBeginning_4aonj_gg_",
35
- "__SEllipsis": "___SEllipsis_4aonj_gg_",
36
- "__SContainer": "___SContainer_4aonj_gg_",
37
- "__SNoTooltipContainer": "___SNoTooltipContainer_4aonj_gg_",
38
- "__SContainerMiddle": "___SContainerMiddle_4aonj_gg_",
39
- "_maxLine": "__maxLine_4aonj_gg_",
40
- "--maxLine": "--maxLine_4aonj",
41
- "_middle-mod": "__middle-mod_4aonj_gg_",
42
- "__STail": "___STail_4aonj_gg_"
27
+ "__SBeginning": "___SBeginning_1x34o_gg_",
28
+ "__SEllipsis": "___SEllipsis_1x34o_gg_",
29
+ "__SContainer": "___SContainer_1x34o_gg_",
30
+ "__SNoTooltipContainer": "___SNoTooltipContainer_1x34o_gg_",
31
+ "__SContainerMiddle": "___SContainerMiddle_1x34o_gg_",
32
+ "_maxLine": "__maxLine_1x34o_gg_",
33
+ "--maxLine": "--maxLine_1x34o",
34
+ "_middle-mod": "__middle-mod_1x34o_gg_",
35
+ "__STail": "___STail_1x34o_gg_"
43
36
  });
44
- var defaultTooltipProps = ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate', 'cursorAnchoring'];
45
- var setFontSettings = function setFontSettings(element, styleElement) {
46
- element.style.fontFamily = styleElement.getPropertyValue('font-family');
47
- element.style.fontSize = styleElement.getPropertyValue('font-size');
48
- element.style.fontWeight = styleElement.getPropertyValue('font-weight');
49
- element.style.lineHeight = styleElement.getPropertyValue('line-height');
50
- element.style.fontFeatureSettings = styleElement.getPropertyValue('font-feature-settings');
51
- element.style.fontVariantNumeric = styleElement.getPropertyValue('font-variant-numeric');
52
- };
53
- var createMeasurerElement = function createMeasurerElement(element, text) {
54
- var styleElement = window.getComputedStyle(element, null);
55
- var temporaryElement = document.createElement('temporary-block');
56
- temporaryElement.style.display = styleElement.getPropertyValue('display');
57
- temporaryElement.style.padding = styleElement.getPropertyValue('padding');
58
- temporaryElement.style.position = 'absolute';
59
- temporaryElement.style.right = '0%';
60
- temporaryElement.style.bottom = '0%';
61
- temporaryElement.style.visibility = 'hidden';
62
- temporaryElement.style.whiteSpace = styleElement.getPropertyValue('white-space');
63
- temporaryElement.style.wordWrap = styleElement.getPropertyValue('word-wrap');
64
- setFontSettings(temporaryElement, styleElement);
65
- temporaryElement.textContent = text !== null && text !== void 0 ? text : element.textContent;
66
- return temporaryElement;
67
- };
68
- function isTextOverflowing(element, multiline, text) {
69
- if (!element) return false;
70
- var _element$getBoundingC = element.getBoundingClientRect(),
71
- currentHeight = _element$getBoundingC.height,
72
- currentWidth = _element$getBoundingC.width;
73
- var measuringElement = createMeasurerElement(element, text);
74
- var isOverflowing = false;
75
- document.body.appendChild(measuringElement);
76
- if (multiline) {
77
- measuringElement.style.width = "".concat(currentWidth, "px");
78
- var width = measuringElement.scrollWidth;
79
- var height = measuringElement.getBoundingClientRect().height;
80
- if (Math.ceil(currentHeight) < height || Math.ceil(currentWidth) < width) {
81
- isOverflowing = true;
82
- }
83
- } else {
84
- measuringElement.style.whiteSpace = 'nowrap';
85
- isOverflowing = Math.ceil(currentWidth) < measuringElement.getBoundingClientRect().width;
86
- }
87
- document.body.removeChild(measuringElement);
88
- return isOverflowing;
89
- }
90
- var forcedAdvancedMode = {
37
+ const defaultTooltipProps = ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate', 'cursorAnchoring'];
38
+ const forcedAdvancedMode = {
91
39
  forcedAdvancedMode: true
92
40
  };
93
- var noAdvancedMode = {};
94
- var RootEllipsis = /*#__PURE__*/function (_Component) {
95
- function RootEllipsis() {
96
- var _this;
97
- (0, _classCallCheck2["default"])(this, RootEllipsis);
98
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
99
- args[_key] = arguments[_key];
100
- }
101
- _this = (0, _callSuper2["default"])(this, RootEllipsis, [].concat(args));
102
- (0, _defineProperty2["default"])(_this, "state", {
41
+ const noAdvancedMode = {};
42
+ class RootEllipsis extends _core.Component {
43
+ constructor(...args) {
44
+ super(...args);
45
+ (0, _defineProperty2.default)(this, "state", {
103
46
  visible: false
104
47
  });
105
- (0, _defineProperty2["default"])(_this, "textRef", /*#__PURE__*/_react["default"].createRef());
106
- (0, _defineProperty2["default"])(_this, "handlerVisibleChange", function (visible) {
107
- _this.setState({
108
- visible: visible && _this.showTooltip()
48
+ (0, _defineProperty2.default)(this, "textRef", /*#__PURE__*/_react.default.createRef());
49
+ (0, _defineProperty2.default)(this, "handlerVisibleChange", visible => {
50
+ this.setState({
51
+ visible: visible && this.showTooltip()
109
52
  });
110
53
  });
111
- return _this;
112
54
  }
113
- (0, _inherits2["default"])(RootEllipsis, _Component);
114
- return (0, _createClass2["default"])(RootEllipsis, [{
115
- key: "showTooltip",
116
- value: function showTooltip() {
117
- var _this$asProps = this.asProps,
118
- _this$asProps$maxLine = _this$asProps.maxLine,
119
- maxLine = _this$asProps$maxLine === void 0 ? 1 : _this$asProps$maxLine,
120
- Children = _this$asProps.Children;
121
- var text = (0, _reactToText["default"])((0, _getOriginChildren["default"])(Children));
122
- return isTextOverflowing(this.textRef.current, maxLine > 1, text);
123
- }
124
- }, {
125
- key: "getContentProps",
126
- value: function getContentProps() {
127
- return {
128
- ref: this.textRef,
129
- maxLine: this.asProps.maxLine
130
- };
131
- }
132
- }, {
133
- key: "getPopperProps",
134
- value: function getPopperProps() {
135
- var _this$asProps2 = this.asProps,
136
- Children = _this$asProps2.Children,
137
- includeTooltipProps = _this$asProps2.includeTooltipProps;
138
- var text = (0, _reactToText["default"])((0, _getOriginChildren["default"])(Children));
139
- var tooltipProps = (0, _pick["default"])(this.asProps, includeTooltipProps);
140
- return (0, _objectSpread2["default"])({
141
- children: text
142
- }, tooltipProps);
143
- }
144
- }, {
145
- key: "render",
146
- value: function render() {
147
- var _ref3, _tooltipProps$visible;
148
- var SEllipsis = this.Root;
149
- var SContainer = _tooltip["default"];
150
- var _this$asProps3 = this.asProps,
151
- styles = _this$asProps3.styles,
152
- Children = _this$asProps3.Children,
153
- maxLine = _this$asProps3.maxLine,
154
- tooltip = _this$asProps3.tooltip,
155
- trim = _this$asProps3.trim,
156
- containerRect = _this$asProps3.containerRect,
157
- containerRef = _this$asProps3.containerRef,
158
- includeTooltipProps = _this$asProps3.includeTooltipProps,
159
- _children = _this$asProps3.children,
160
- other = (0, _objectWithoutProperties2["default"])(_this$asProps3, _excluded);
161
- var visible = this.state.visible;
162
- var advancedContent = (0, _findComponent["default"])(Children, [Ellipsis.Content.displayName]);
163
- var text = (0, _reactToText["default"])(advancedContent || (0, _getOriginChildren["default"])(Children));
164
- var advanceMode = (0, _findComponent.isAdvanceMode)(Children, [Ellipsis.Content.displayName, Ellipsis.Popper.displayName]);
165
- var tooltipProps = (0, _pick["default"])(this.asProps, includeTooltipProps);
166
- tooltipProps.visible = (_tooltipProps$visible = tooltipProps.visible) !== null && _tooltipProps$visible !== void 0 ? _tooltipProps$visible : visible;
167
- tooltipProps.onVisibleChange = tooltipProps.onVisibleChange ? (0, _assignProps3.callAllEventHandlers)(tooltipProps.onVisibleChange, this.handlerVisibleChange) : this.handlerVisibleChange;
168
- if (trim === 'middle') {
169
- var _ref2;
170
- return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(EllipsisMiddle, _ref2.cn("EllipsisMiddle", (0, _objectSpread2["default"])({
171
- "text": text,
172
- "styles": styles,
173
- "tooltip": tooltip,
174
- "containerRect": containerRect,
175
- "containerRef": containerRef,
176
- "textRef": this.textRef,
177
- "tooltipProps": tooltipProps,
178
- "advanceMode": advanceMode
179
- }, other)), /*#__PURE__*/_react["default"].createElement(Children, _ref2.cn("Children", {})));
180
- }
181
- return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SContainer, _ref3.cn("SContainer", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
182
- "interaction": tooltip ? 'hover' : 'none',
183
- "title": !advanceMode ? text : undefined
184
- }, tooltipProps), advanceMode ? forcedAdvancedMode : noAdvancedMode)), advanceMode ? /*#__PURE__*/_react["default"].createElement(Children, _ref3.cn("Children", {})) : /*#__PURE__*/_react["default"].createElement(SEllipsis, _ref3.cn("SEllipsis", (0, _objectSpread2["default"])({
185
- "render": _flexBox.Box,
186
- "ref": this.textRef,
187
- "maxLine": maxLine
188
- }, other)), /*#__PURE__*/_react["default"].createElement(Children, _ref3.cn("Children", {}))));
55
+ showTooltip() {
56
+ const {
57
+ maxLine = 1,
58
+ Children
59
+ } = this.asProps;
60
+ const text = (0, _reactToText.default)((0, _getOriginChildren.default)(Children));
61
+ return (0, _utils.isTextOverflowing)(this.textRef.current, maxLine > 1, text);
62
+ }
63
+ getContentProps() {
64
+ return {
65
+ ref: this.textRef,
66
+ maxLine: this.asProps.maxLine
67
+ };
68
+ }
69
+ getPopperProps() {
70
+ const {
71
+ Children,
72
+ includeTooltipProps
73
+ } = this.asProps;
74
+ const text = (0, _reactToText.default)((0, _getOriginChildren.default)(Children));
75
+ const tooltipProps = (0, _pick.default)(this.asProps, includeTooltipProps);
76
+ return {
77
+ children: text,
78
+ ...tooltipProps
79
+ };
80
+ }
81
+ render() {
82
+ var _ref3;
83
+ const SEllipsis = this.Root;
84
+ const SContainer = _tooltip.default;
85
+ const {
86
+ styles,
87
+ Children,
88
+ maxLine,
89
+ tooltip,
90
+ trim,
91
+ containerRect,
92
+ containerRef,
93
+ includeTooltipProps,
94
+ children: _children,
95
+ ...other
96
+ } = this.asProps;
97
+ const {
98
+ visible
99
+ } = this.state;
100
+ const advancedContent = (0, _findComponent.default)(Children, [Ellipsis.Content.displayName]);
101
+ const text = (0, _reactToText.default)(advancedContent || (0, _getOriginChildren.default)(Children));
102
+ const advanceMode = (0, _findComponent.isAdvanceMode)(Children, [Ellipsis.Content.displayName, Ellipsis.Popper.displayName]);
103
+ const tooltipProps = (0, _pick.default)(this.asProps, includeTooltipProps);
104
+ tooltipProps.visible = tooltipProps.visible ?? visible;
105
+ tooltipProps.onVisibleChange = tooltipProps.onVisibleChange ? (0, _assignProps3.callAllEventHandlers)(tooltipProps.onVisibleChange, this.handlerVisibleChange) : this.handlerVisibleChange;
106
+ if (trim === 'middle') {
107
+ var _ref2;
108
+ return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(EllipsisMiddle, _ref2.cn("EllipsisMiddle", {
109
+ "text": text,
110
+ "styles": styles,
111
+ "tooltip": tooltip,
112
+ "containerRect": containerRect,
113
+ "containerRef": containerRef,
114
+ "textRef": this.textRef,
115
+ "tooltipProps": tooltipProps,
116
+ "advanceMode": advanceMode,
117
+ ...other
118
+ }), /*#__PURE__*/_react.default.createElement(Children, _ref2.cn("Children", {})));
189
119
  }
190
- }]);
191
- }(_core.Component);
192
- (0, _defineProperty2["default"])(RootEllipsis, "displayName", 'Ellipsis');
193
- (0, _defineProperty2["default"])(RootEllipsis, "style", style);
194
- (0, _defineProperty2["default"])(RootEllipsis, "defaultProps", {
120
+ return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SContainer, _ref3.cn("SContainer", {
121
+ "interaction": tooltip ? 'hover' : 'none',
122
+ "title": !advanceMode ? text : undefined,
123
+ ...tooltipProps,
124
+ ...(advanceMode ? forcedAdvancedMode : noAdvancedMode)
125
+ }), advanceMode ? /*#__PURE__*/_react.default.createElement(Children, _ref3.cn("Children", {})) : /*#__PURE__*/_react.default.createElement(SEllipsis, _ref3.cn("SEllipsis", {
126
+ "render": _baseComponents.Box,
127
+ "ref": this.textRef,
128
+ "maxLine": maxLine,
129
+ ...other
130
+ }), /*#__PURE__*/_react.default.createElement(Children, _ref3.cn("Children", {}))));
131
+ }
132
+ }
133
+ (0, _defineProperty2.default)(RootEllipsis, "displayName", 'Ellipsis');
134
+ (0, _defineProperty2.default)(RootEllipsis, "style", style);
135
+ (0, _defineProperty2.default)(RootEllipsis, "defaultProps", {
195
136
  trim: 'end',
196
137
  tooltip: true,
197
138
  includeTooltipProps: defaultTooltipProps,
198
139
  __excludeProps: ['title']
199
140
  });
200
- var EllipsisMiddleContext = /*#__PURE__*/_react["default"].createContext(null);
201
- var EllipsisMiddle = function EllipsisMiddle(props) {
141
+ const EllipsisMiddleContext = /*#__PURE__*/_react.default.createContext(null);
142
+ function EllipsisMiddle(props) {
202
143
  var _ref5;
203
- var styles = props.styles,
204
- text = props.text,
205
- tooltip = props.tooltip,
206
- containerRect = props.containerRect,
207
- containerRef = props.containerRef,
208
- textRef = props.textRef,
209
- tooltipProps = props.tooltipProps,
210
- children = props.children,
211
- advanceMode = props.advanceMode,
212
- tag = props.tag;
213
- var resizeElement = _react["default"].useRef(null);
214
- var _React$useState = _react["default"].useState(0),
215
- _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
216
- symbolWidth = _React$useState2[0],
217
- setSymbolWidth = _React$useState2[1];
218
- var blockWidth = (0, _useResizeObserver.useResizeObserver)(resizeElement, containerRect).width;
219
- (0, _useEnhancedEffect["default"])(function () {
220
- var node = (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) || (resizeElement === null || resizeElement === void 0 ? void 0 : resizeElement.current);
144
+ const {
145
+ styles,
146
+ text,
147
+ tooltip,
148
+ containerRect,
149
+ containerRef,
150
+ textRef,
151
+ tooltipProps,
152
+ children,
153
+ advanceMode,
154
+ tag
155
+ } = props;
156
+ const resizeElement = _react.default.useRef(null);
157
+ const [symbolWidth, setSymbolWidth] = _react.default.useState(0);
158
+ const blockWidth = (0, _useResizeObserver.useResizeObserver)(resizeElement, containerRect).width;
159
+ (0, _useEnhancedEffect.default)(() => {
160
+ const node = containerRef?.current || resizeElement?.current;
221
161
  if (!node) return;
222
- var styleElement = window.getComputedStyle(node);
223
- var dateSpan = document.createElement('temporary-block');
224
- setFontSettings(dateSpan, styleElement);
162
+ const styleElement = window.getComputedStyle(node);
163
+ const dateSpan = document.createElement('temporary-block');
164
+ (0, _utils.setFontSettings)(dateSpan, styleElement);
225
165
  dateSpan.textContent = 'a';
226
166
  document.body.appendChild(dateSpan);
227
- var rect = dateSpan.getBoundingClientRect();
167
+ const rect = dateSpan.getBoundingClientRect();
228
168
  setSymbolWidth(rect.width);
229
169
  document.body.removeChild(dateSpan);
230
170
  }, []);
231
- var STail = 'span';
232
- var SBeginning = 'span';
233
- var SContainerMiddle = _tooltip["default"];
234
- var SAdvancedModeContainerMiddle = _tooltip["default"];
235
- var displayedSymbols = _react["default"].useMemo(function () {
236
- var displayedSymbols = Math.round(blockWidth / symbolWidth);
171
+ const STail = 'span';
172
+ const SBeginning = 'span';
173
+ const SContainerMiddle = _tooltip.default;
174
+ const SAdvancedModeContainerMiddle = _tooltip.default;
175
+ const displayedSymbols = _react.default.useMemo(() => {
176
+ const displayedSymbols = Math.round(blockWidth / symbolWidth);
237
177
  return displayedSymbols % 2 === 0 ? displayedSymbols : displayedSymbols - 1;
238
178
  }, [blockWidth, symbolWidth]);
239
- var interaction = text.length > displayedSymbols ? 'hover' : 'none';
240
- var ref = containerRef !== null && containerRef !== void 0 ? containerRef : resizeElement;
241
- var contextValue = _react["default"].useMemo(function () {
242
- return {
243
- begining: text.substring(0, text.length - displayedSymbols / 2 - 1),
244
- tail: text.substring(text.length - displayedSymbols / 2 - 1),
245
- ref: ref
246
- };
247
- }, [text, displayedSymbols]);
179
+ const interaction = text.length > displayedSymbols ? 'hover' : 'none';
180
+ const ref = containerRef ?? resizeElement;
181
+ const contextValue = _react.default.useMemo(() => ({
182
+ begining: text.substring(0, text.length - displayedSymbols / 2 - 1),
183
+ tail: text.substring(text.length - displayedSymbols / 2 - 1),
184
+ ref
185
+ }), [text, displayedSymbols]);
248
186
  if (advanceMode) {
249
187
  var _ref4;
250
- return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SAdvancedModeContainerMiddle, _ref4.cn("SAdvancedModeContainerMiddle", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
251
- "interaction": tooltip ? interaction : 'none'
252
- }, tooltipProps), forcedAdvancedMode)), /*#__PURE__*/_react["default"].createElement(EllipsisMiddleContext.Provider, {
188
+ return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SAdvancedModeContainerMiddle, _ref4.cn("SAdvancedModeContainerMiddle", {
189
+ "interaction": tooltip ? interaction : 'none',
190
+ ...tooltipProps,
191
+ ...forcedAdvancedMode
192
+ }), /*#__PURE__*/_react.default.createElement(EllipsisMiddleContext.Provider, {
253
193
  value: contextValue
254
194
  }, children));
255
195
  }
256
- return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SContainerMiddle, _ref5.cn("SContainerMiddle", (0, _objectSpread2["default"])({
196
+ return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SContainerMiddle, _ref5.cn("SContainerMiddle", {
257
197
  "interaction": tooltip ? interaction : 'none',
258
198
  "title": text,
259
- "ref": (0, _ref9.forkRef)(ref, textRef),
260
- "tag": tag
261
- }, tooltipProps)), /*#__PURE__*/_react["default"].createElement(SBeginning, _ref5.cn("SBeginning", {}), contextValue.begining), /*#__PURE__*/_react["default"].createElement(STail, _ref5.cn("STail", {}), contextValue.tail));
262
- };
263
- var Content = function Content(_ref8) {
199
+ "ref": (0, _ref8.forkRef)(ref, textRef),
200
+ "tag": tag,
201
+ ...tooltipProps
202
+ }), /*#__PURE__*/_react.default.createElement(SBeginning, _ref5.cn("SBeginning", {}), contextValue.begining), /*#__PURE__*/_react.default.createElement(STail, _ref5.cn("STail", {}), contextValue.tail));
203
+ }
204
+ function Content({
205
+ styles,
206
+ Children
207
+ }) {
264
208
  var _ref = arguments[0],
265
209
  _ref7;
266
- var styles = _ref8.styles,
267
- Children = _ref8.Children;
268
- var SEllipsis = _tooltip["default"].Trigger;
269
- var ellipsisMiddleContext = _react["default"].useContext(EllipsisMiddleContext);
270
- var STail = 'span';
271
- var SBeginning = 'span';
210
+ const SEllipsis = _tooltip.default.Trigger;
211
+ const ellipsisMiddleContext = _react.default.useContext(EllipsisMiddleContext);
212
+ const STail = 'span';
213
+ const SBeginning = 'span';
272
214
  if (ellipsisMiddleContext) {
273
215
  var _ref6;
274
- var begining = ellipsisMiddleContext.begining,
275
- tail = ellipsisMiddleContext.tail,
276
- ref = ellipsisMiddleContext.ref;
277
- return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SEllipsis, _ref6.cn("SEllipsis", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
278
- "middle-mod": true,
279
- "ref": ref
280
- }, _ref))), /*#__PURE__*/_react["default"].createElement(SBeginning, _ref6.cn("SBeginning", {}), begining), /*#__PURE__*/_react["default"].createElement(STail, _ref6.cn("STail", {}), tail));
216
+ const {
217
+ begining,
218
+ tail,
219
+ ref
220
+ } = ellipsisMiddleContext;
221
+ return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SEllipsis, _ref6.cn("SEllipsis", {
222
+ ...(0, _core.assignProps)({
223
+ "middle-mod": true,
224
+ "ref": ref
225
+ }, _ref)
226
+ }), /*#__PURE__*/_react.default.createElement(SBeginning, _ref6.cn("SBeginning", {}), begining), /*#__PURE__*/_react.default.createElement(STail, _ref6.cn("STail", {}), tail));
281
227
  }
282
- return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SEllipsis, _ref7.cn("SEllipsis", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref))), /*#__PURE__*/_react["default"].createElement(Children, _ref7.cn("Children", {})));
283
- };
284
- var Ellipsis = (0, _core.createComponent)(RootEllipsis, {
285
- Content: Content,
286
- Popper: _tooltip["default"].Popper
228
+ return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SEllipsis, _ref7.cn("SEllipsis", {
229
+ ...(0, _core.assignProps)({}, _ref)
230
+ }), /*#__PURE__*/_react.default.createElement(Children, _ref7.cn("Children", {})));
231
+ }
232
+ const Ellipsis = (0, _core.createComponent)(RootEllipsis, {
233
+ Content,
234
+ Popper: _tooltip.default.Popper
287
235
  });
288
- var _default = exports["default"] = Ellipsis;
236
+ var _default = exports.default = Ellipsis;
289
237
  //# sourceMappingURL=Ellipsis.js.map