@semcore/ellipsis 16.0.12-prerelease.37 → 16.1.0-prerelease.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/lib/cjs/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  Object.defineProperty(exports, "default", {
8
8
  enumerable: true,
9
- get: function () {
10
- return _Ellipsis.default;
9
+ get: function get() {
10
+ return _Ellipsis["default"];
11
11
  }
12
12
  });
13
13
  Object.defineProperty(exports, "useResizeObserver", {
14
14
  enumerable: true,
15
- get: function () {
15
+ get: function get() {
16
16
  return _useResizeObserver.useResizeObserver;
17
17
  }
18
18
  });
@@ -1,31 +1,35 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useResizeObserver = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
9
  var _canUseDOM = _interopRequireDefault(require("@semcore/core/lib/utils/canUseDOM"));
9
10
  var _useEnhancedEffect = _interopRequireDefault(require("@semcore/core/lib/utils/use/useEnhancedEffect"));
10
11
  var _react = _interopRequireDefault(require("react"));
11
- const useResizeObserver = (ref, hookOverride) => {
12
- const [width, setWidth] = _react.default.useState(0);
13
- const handleResize = _react.default.useCallback(entries => {
12
+ var useResizeObserver = exports.useResizeObserver = function useResizeObserver(ref, hookOverride) {
13
+ var _React$useState = _react["default"].useState(0),
14
+ _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
15
+ width = _React$useState2[0],
16
+ setWidth = _React$useState2[1];
17
+ var handleResize = _react["default"].useCallback(function (entries) {
14
18
  setWidth(entries[0].contentRect.width);
15
19
  }, []);
16
- (0, _useEnhancedEffect.default)(() => {
20
+ (0, _useEnhancedEffect["default"])(function () {
17
21
  if (!ref.current) {
18
22
  return;
19
23
  }
20
24
  if (hookOverride) {
21
25
  return;
22
26
  }
23
- if ((0, _canUseDOM.default)()) {
24
- const ro = new ResizeObserver(entries => {
27
+ if ((0, _canUseDOM["default"])()) {
28
+ var ro = new ResizeObserver(function (entries) {
25
29
  handleResize(entries);
26
30
  });
27
31
  ro.observe(ref.current);
28
- return () => {
32
+ return function () {
29
33
  ro.disconnect();
30
34
  };
31
35
  }
@@ -34,8 +38,7 @@ const useResizeObserver = (ref, hookOverride) => {
34
38
  return hookOverride;
35
39
  }
36
40
  return {
37
- width
41
+ width: width
38
42
  };
39
43
  };
40
- exports.useResizeObserver = useResizeObserver;
41
44
  //# sourceMappingURL=useResizeObserver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResizeObserver.js","names":["_canUseDOM","_interopRequireDefault","require","_useEnhancedEffect","_react","useResizeObserver","ref","hookOverride","width","setWidth","React","useState","handleResize","useCallback","entries","contentRect","useEnhancedEffect","current","canUseDOM","ro","ResizeObserver","observe","disconnect","exports"],"sources":["../../src/useResizeObserver.tsx"],"sourcesContent":["import canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';\nimport React, { type RefObject } from 'react';\n\nexport const useResizeObserver = (\n ref: RefObject<HTMLElement>,\n hookOverride?: { width: number },\n) => {\n const [width, setWidth] = React.useState<number>(0);\n\n const handleResize = React.useCallback((entries: ResizeObserverEntry[]) => {\n setWidth(entries[0].contentRect.width);\n }, []);\n\n useEnhancedEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (hookOverride) {\n return;\n }\n if (canUseDOM()) {\n const ro = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n handleResize(entries);\n });\n\n ro.observe(ref.current);\n\n return () => {\n ro.disconnect();\n };\n }\n }, [hookOverride]);\n\n if (hookOverride) {\n return hookOverride;\n }\n return { width };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEO,MAAMG,iBAAiB,GAAGA,CAC/BC,GAA2B,EAC3BC,YAAgC,KAC7B;EACH,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAS,CAAC,CAAC;EAEnD,MAAMC,YAAY,GAAGF,cAAK,CAACG,WAAW,CAAEC,OAA8B,IAAK;IACzEL,QAAQ,CAACK,OAAO,CAAC,CAAC,CAAC,CAACC,WAAW,CAACP,KAAK,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAQ,0BAAiB,EAAC,MAAM;IACtB,IAAI,CAACV,GAAG,CAACW,OAAO,EAAE;MAChB;IACF;IAEA,IAAIV,YAAY,EAAE;MAChB;IACF;IACA,IAAI,IAAAW,kBAAS,EAAC,CAAC,EAAE;MACf,MAAMC,EAAE,GAAG,IAAIC,cAAc,CAAEN,OAA8B,IAAK;QAChEF,YAAY,CAACE,OAAO,CAAC;MACvB,CAAC,CAAC;MAEFK,EAAE,CAACE,OAAO,CAACf,GAAG,CAACW,OAAO,CAAC;MAEvB,OAAO,MAAM;QACXE,EAAE,CAACG,UAAU,CAAC,CAAC;MACjB,CAAC;IACH;EACF,CAAC,EAAE,CAACf,YAAY,CAAC,CAAC;EAElB,IAAIA,YAAY,EAAE;IAChB,OAAOA,YAAY;EACrB;EACA,OAAO;IAAEC;EAAM,CAAC;AAClB,CAAC;AAACe,OAAA,CAAAlB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"useResizeObserver.js","names":["_canUseDOM","_interopRequireDefault","require","_useEnhancedEffect","_react","useResizeObserver","exports","ref","hookOverride","_React$useState","React","useState","_React$useState2","_slicedToArray2","width","setWidth","handleResize","useCallback","entries","contentRect","useEnhancedEffect","current","canUseDOM","ro","ResizeObserver","observe","disconnect"],"sources":["../../src/useResizeObserver.tsx"],"sourcesContent":["import canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';\nimport React, { type RefObject } from 'react';\n\nexport const useResizeObserver = (\n ref: RefObject<HTMLElement>,\n hookOverride?: { width: number },\n) => {\n const [width, setWidth] = React.useState<number>(0);\n\n const handleResize = React.useCallback((entries: ResizeObserverEntry[]) => {\n setWidth(entries[0].contentRect.width);\n }, []);\n\n useEnhancedEffect(() => {\n if (!ref.current) {\n return;\n }\n\n if (hookOverride) {\n return;\n }\n if (canUseDOM()) {\n const ro = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n handleResize(entries);\n });\n\n ro.observe(ref.current);\n\n return () => {\n ro.disconnect();\n };\n }\n }, [hookOverride]);\n\n if (hookOverride) {\n return hookOverride;\n }\n return { width };\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEO,IAAMG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,SAApBA,iBAAiBA,CAC5BE,GAA2B,EAC3BC,YAAgC,EAC7B;EACH,IAAAC,eAAA,GAA0BC,iBAAK,CAACC,QAAQ,CAAS,CAAC,CAAC;IAAAC,gBAAA,OAAAC,eAAA,aAAAJ,eAAA;IAA5CK,KAAK,GAAAF,gBAAA;IAAEG,QAAQ,GAAAH,gBAAA;EAEtB,IAAMI,YAAY,GAAGN,iBAAK,CAACO,WAAW,CAAC,UAACC,OAA8B,EAAK;IACzEH,QAAQ,CAACG,OAAO,CAAC,CAAC,CAAC,CAACC,WAAW,CAACL,KAAK,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAEN,IAAAM,6BAAiB,EAAC,YAAM;IACtB,IAAI,CAACb,GAAG,CAACc,OAAO,EAAE;MAChB;IACF;IAEA,IAAIb,YAAY,EAAE;MAChB;IACF;IACA,IAAI,IAAAc,qBAAS,EAAC,CAAC,EAAE;MACf,IAAMC,EAAE,GAAG,IAAIC,cAAc,CAAC,UAACN,OAA8B,EAAK;QAChEF,YAAY,CAACE,OAAO,CAAC;MACvB,CAAC,CAAC;MAEFK,EAAE,CAACE,OAAO,CAAClB,GAAG,CAACc,OAAO,CAAC;MAEvB,OAAO,YAAM;QACXE,EAAE,CAACG,UAAU,CAAC,CAAC;MACjB,CAAC;IACH;EACF,CAAC,EAAE,CAAClB,YAAY,CAAC,CAAC;EAElB,IAAIA,YAAY,EAAE;IAChB,OAAOA,YAAY;EACrB;EACA,OAAO;IAAEM,KAAK,EAALA;EAAM,CAAC;AAClB,CAAC","ignoreList":[]}
@@ -1,8 +1,15 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
4
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
+ import _createClass from "@babel/runtime/helpers/createClass";
6
+ import _callSuper from "@babel/runtime/helpers/callSuper";
7
+ import _inherits from "@babel/runtime/helpers/inherits";
1
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
9
  import { sstyled as _sstyled } from "@semcore/core";
3
10
  import { assignProps as _assignProps2 } from "@semcore/core";
4
11
  import { assignProps as _assignProps } from "@semcore/core";
5
- import { Box } from '@semcore/base-components';
12
+ var _excluded = ["styles", "Children", "maxLine", "tooltip", "trim", "containerRect", "containerRef", "includeTooltipProps", "children"];
6
13
  import { createComponent, Component, Root, sstyled } from '@semcore/core';
7
14
  import { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';
8
15
  import findComponent, { isAdvanceMode } from '@semcore/core/lib/utils/findComponent';
@@ -11,120 +18,172 @@ import pick from '@semcore/core/lib/utils/pick';
11
18
  import reactToText from '@semcore/core/lib/utils/reactToText';
12
19
  import { forkRef } from '@semcore/core/lib/utils/ref';
13
20
  import useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';
21
+ import { Box } from '@semcore/flex-box';
14
22
  import Tooltip from '@semcore/tooltip';
15
23
  import React from 'react';
16
24
  /*!__reshadow-styles__:"./style/ellipsis.shadow.css"*/
17
- const style = (/*__reshadow_css_start__*/_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_"),
25
+ var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SBeginning_bcnty_gg_,.___SEllipsis_bcnty_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SEllipsis_bcnty_gg_.__maxLine_bcnty_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_bcnty);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SContainerMiddle_bcnty_gg_,.___SContainer_bcnty_gg_,.___SEllipsis_bcnty_gg_.__middle-mod_bcnty_gg_,.___SNoTooltipContainer_bcnty_gg_{display:flex;overflow:hidden}.___SContainerMiddle_bcnty_gg_>:has(.___SBeginning_bcnty_gg_),.___SContainerMiddle_bcnty_gg_>:has(.___STail_bcnty_gg_){display:flex;width:100%}.___STail_bcnty_gg_{white-space:pre}", /*__inner_css_end__*/"bcnty_gg_"),
18
26
  /*__reshadow_css_end__*/
19
27
  {
20
- "__SBeginning": "___SBeginning_4aonj_gg_",
21
- "__SEllipsis": "___SEllipsis_4aonj_gg_",
22
- "__SContainer": "___SContainer_4aonj_gg_",
23
- "__SNoTooltipContainer": "___SNoTooltipContainer_4aonj_gg_",
24
- "__SContainerMiddle": "___SContainerMiddle_4aonj_gg_",
25
- "_maxLine": "__maxLine_4aonj_gg_",
26
- "--maxLine": "--maxLine_4aonj",
27
- "_middle-mod": "__middle-mod_4aonj_gg_",
28
- "__STail": "___STail_4aonj_gg_"
28
+ "__SBeginning": "___SBeginning_bcnty_gg_",
29
+ "__SEllipsis": "___SEllipsis_bcnty_gg_",
30
+ "__SContainer": "___SContainer_bcnty_gg_",
31
+ "__SNoTooltipContainer": "___SNoTooltipContainer_bcnty_gg_",
32
+ "__SContainerMiddle": "___SContainerMiddle_bcnty_gg_",
33
+ "_maxLine": "__maxLine_bcnty_gg_",
34
+ "--maxLine": "--maxLine_bcnty",
35
+ "_middle-mod": "__middle-mod_bcnty_gg_",
36
+ "__STail": "___STail_bcnty_gg_"
29
37
  });
30
38
  import { useResizeObserver } from './useResizeObserver';
31
- import { isTextOverflowing, setFontSettings } from './utils';
32
- const defaultTooltipProps = ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate', 'cursorAnchoring'];
33
- const forcedAdvancedMode = {
39
+ var defaultTooltipProps = ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate', 'cursorAnchoring'];
40
+ var setFontSettings = function setFontSettings(element, styleElement) {
41
+ element.style.fontFamily = styleElement.getPropertyValue('font-family');
42
+ element.style.fontSize = styleElement.getPropertyValue('font-size');
43
+ element.style.fontWeight = styleElement.getPropertyValue('font-weight');
44
+ element.style.lineHeight = styleElement.getPropertyValue('line-height');
45
+ element.style.fontFeatureSettings = styleElement.getPropertyValue('font-feature-settings');
46
+ element.style.fontVariantNumeric = styleElement.getPropertyValue('font-variant-numeric');
47
+ };
48
+ var createMeasurerElement = function createMeasurerElement(element, text) {
49
+ var styleElement = window.getComputedStyle(element, null);
50
+ var temporaryElement = document.createElement('temporary-block');
51
+ temporaryElement.style.display = styleElement.getPropertyValue('display');
52
+ temporaryElement.style.padding = styleElement.getPropertyValue('padding');
53
+ temporaryElement.style.position = 'absolute';
54
+ temporaryElement.style.right = '0%';
55
+ temporaryElement.style.bottom = '0%';
56
+ temporaryElement.style.visibility = 'hidden';
57
+ temporaryElement.style.whiteSpace = styleElement.getPropertyValue('white-space');
58
+ temporaryElement.style.wordWrap = styleElement.getPropertyValue('word-wrap');
59
+ setFontSettings(temporaryElement, styleElement);
60
+ temporaryElement.textContent = text !== null && text !== void 0 ? text : element.textContent;
61
+ return temporaryElement;
62
+ };
63
+ function isTextOverflowing(element, multiline, text) {
64
+ if (!element) return false;
65
+ var _element$getBoundingC = element.getBoundingClientRect(),
66
+ currentHeight = _element$getBoundingC.height,
67
+ currentWidth = _element$getBoundingC.width;
68
+ var measuringElement = createMeasurerElement(element, text);
69
+ var isOverflowing = false;
70
+ document.body.appendChild(measuringElement);
71
+ if (multiline) {
72
+ measuringElement.style.width = "".concat(currentWidth, "px");
73
+ var width = measuringElement.scrollWidth;
74
+ var height = measuringElement.getBoundingClientRect().height;
75
+ if (Math.ceil(currentHeight) < height || Math.ceil(currentWidth) < width) {
76
+ isOverflowing = true;
77
+ }
78
+ } else {
79
+ measuringElement.style.whiteSpace = 'nowrap';
80
+ isOverflowing = Math.ceil(currentWidth) < measuringElement.getBoundingClientRect().width;
81
+ }
82
+ document.body.removeChild(measuringElement);
83
+ return isOverflowing;
84
+ }
85
+ var forcedAdvancedMode = {
34
86
  forcedAdvancedMode: true
35
87
  };
36
- const noAdvancedMode = {};
37
- class RootEllipsis extends Component {
38
- constructor(...args) {
39
- super(...args);
40
- _defineProperty(this, "state", {
88
+ var noAdvancedMode = {};
89
+ var RootEllipsis = /*#__PURE__*/function (_Component) {
90
+ function RootEllipsis() {
91
+ var _this;
92
+ _classCallCheck(this, RootEllipsis);
93
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
94
+ args[_key] = arguments[_key];
95
+ }
96
+ _this = _callSuper(this, RootEllipsis, [].concat(args));
97
+ _defineProperty(_this, "state", {
41
98
  visible: false
42
99
  });
43
- _defineProperty(this, "textRef", /*#__PURE__*/React.createRef());
44
- _defineProperty(this, "handlerVisibleChange", visible => {
45
- this.setState({
46
- visible: visible && this.showTooltip()
100
+ _defineProperty(_this, "textRef", /*#__PURE__*/React.createRef());
101
+ _defineProperty(_this, "handlerVisibleChange", function (visible) {
102
+ _this.setState({
103
+ visible: visible && _this.showTooltip()
47
104
  });
48
105
  });
106
+ return _this;
49
107
  }
50
- showTooltip() {
51
- const {
52
- maxLine = 1,
53
- Children
54
- } = this.asProps;
55
- const text = reactToText(getOriginChildren(Children));
56
- return isTextOverflowing(this.textRef.current, maxLine > 1, text);
57
- }
58
- getContentProps() {
59
- return {
60
- ref: this.textRef,
61
- maxLine: this.asProps.maxLine
62
- };
63
- }
64
- getPopperProps() {
65
- const {
66
- Children,
67
- includeTooltipProps
68
- } = this.asProps;
69
- const text = reactToText(getOriginChildren(Children));
70
- const tooltipProps = pick(this.asProps, includeTooltipProps);
71
- return {
72
- children: text,
73
- ...tooltipProps
74
- };
75
- }
76
- render() {
77
- var _ref3;
78
- const SEllipsis = this.Root;
79
- const SContainer = Tooltip;
80
- const {
81
- styles,
82
- Children,
83
- maxLine,
84
- tooltip,
85
- trim,
86
- containerRect,
87
- containerRef,
88
- includeTooltipProps,
89
- children: _children,
90
- ...other
91
- } = this.asProps;
92
- const {
93
- visible
94
- } = this.state;
95
- const advancedContent = findComponent(Children, [Ellipsis.Content.displayName]);
96
- const text = reactToText(advancedContent || getOriginChildren(Children));
97
- const advanceMode = isAdvanceMode(Children, [Ellipsis.Content.displayName, Ellipsis.Popper.displayName]);
98
- const tooltipProps = pick(this.asProps, includeTooltipProps);
99
- tooltipProps.visible = tooltipProps.visible ?? visible;
100
- tooltipProps.onVisibleChange = tooltipProps.onVisibleChange ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange) : this.handlerVisibleChange;
101
- if (trim === 'middle') {
102
- var _ref2;
103
- return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(EllipsisMiddle, _ref2.cn("EllipsisMiddle", {
104
- "text": text,
105
- "styles": styles,
106
- "tooltip": tooltip,
107
- "containerRect": containerRect,
108
- "containerRef": containerRef,
109
- "textRef": this.textRef,
110
- "tooltipProps": tooltipProps,
111
- "advanceMode": advanceMode,
112
- ...other
113
- }), /*#__PURE__*/React.createElement(Children, _ref2.cn("Children", {})));
108
+ _inherits(RootEllipsis, _Component);
109
+ return _createClass(RootEllipsis, [{
110
+ key: "showTooltip",
111
+ value: function showTooltip() {
112
+ var _this$asProps = this.asProps,
113
+ _this$asProps$maxLine = _this$asProps.maxLine,
114
+ maxLine = _this$asProps$maxLine === void 0 ? 1 : _this$asProps$maxLine,
115
+ Children = _this$asProps.Children;
116
+ var text = reactToText(getOriginChildren(Children));
117
+ return isTextOverflowing(this.textRef.current, maxLine > 1, text);
114
118
  }
115
- return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(SContainer, _ref3.cn("SContainer", {
116
- "interaction": tooltip ? 'hover' : 'none',
117
- "title": !advanceMode ? text : undefined,
118
- ...tooltipProps,
119
- ...(advanceMode ? forcedAdvancedMode : noAdvancedMode)
120
- }), advanceMode ? /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})) : /*#__PURE__*/React.createElement(SEllipsis, _ref3.cn("SEllipsis", {
121
- "render": Box,
122
- "ref": this.textRef,
123
- "maxLine": maxLine,
124
- ...other
125
- }), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {}))));
126
- }
127
- }
119
+ }, {
120
+ key: "getContentProps",
121
+ value: function getContentProps() {
122
+ return {
123
+ ref: this.textRef,
124
+ maxLine: this.asProps.maxLine
125
+ };
126
+ }
127
+ }, {
128
+ key: "getPopperProps",
129
+ value: function getPopperProps() {
130
+ var _this$asProps2 = this.asProps,
131
+ Children = _this$asProps2.Children,
132
+ includeTooltipProps = _this$asProps2.includeTooltipProps;
133
+ var text = reactToText(getOriginChildren(Children));
134
+ var tooltipProps = pick(this.asProps, includeTooltipProps);
135
+ return _objectSpread({
136
+ children: text
137
+ }, tooltipProps);
138
+ }
139
+ }, {
140
+ key: "render",
141
+ value: function render() {
142
+ var _ref3, _tooltipProps$visible;
143
+ var SEllipsis = this.Root;
144
+ var SContainer = Tooltip;
145
+ var _this$asProps3 = this.asProps,
146
+ styles = _this$asProps3.styles,
147
+ Children = _this$asProps3.Children,
148
+ maxLine = _this$asProps3.maxLine,
149
+ tooltip = _this$asProps3.tooltip,
150
+ trim = _this$asProps3.trim,
151
+ containerRect = _this$asProps3.containerRect,
152
+ containerRef = _this$asProps3.containerRef,
153
+ includeTooltipProps = _this$asProps3.includeTooltipProps,
154
+ _children = _this$asProps3.children,
155
+ other = _objectWithoutProperties(_this$asProps3, _excluded);
156
+ var visible = this.state.visible;
157
+ var advancedContent = findComponent(Children, [Ellipsis.Content.displayName]);
158
+ var text = reactToText(advancedContent || getOriginChildren(Children));
159
+ var advanceMode = isAdvanceMode(Children, [Ellipsis.Content.displayName, Ellipsis.Popper.displayName]);
160
+ var tooltipProps = pick(this.asProps, includeTooltipProps);
161
+ tooltipProps.visible = (_tooltipProps$visible = tooltipProps.visible) !== null && _tooltipProps$visible !== void 0 ? _tooltipProps$visible : visible;
162
+ tooltipProps.onVisibleChange = tooltipProps.onVisibleChange ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange) : this.handlerVisibleChange;
163
+ if (trim === 'middle') {
164
+ var _ref2;
165
+ return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(EllipsisMiddle, _ref2.cn("EllipsisMiddle", _objectSpread({
166
+ "text": text,
167
+ "styles": styles,
168
+ "tooltip": tooltip,
169
+ "containerRect": containerRect,
170
+ "containerRef": containerRef,
171
+ "textRef": this.textRef,
172
+ "tooltipProps": tooltipProps,
173
+ "advanceMode": advanceMode
174
+ }, other)), /*#__PURE__*/React.createElement(Children, _ref2.cn("Children", {})));
175
+ }
176
+ return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(SContainer, _ref3.cn("SContainer", _objectSpread(_objectSpread({
177
+ "interaction": tooltip ? 'hover' : 'none',
178
+ "title": !advanceMode ? text : undefined
179
+ }, tooltipProps), advanceMode ? forcedAdvancedMode : noAdvancedMode)), advanceMode ? /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})) : /*#__PURE__*/React.createElement(SEllipsis, _ref3.cn("SEllipsis", _objectSpread({
180
+ "render": Box,
181
+ "ref": this.textRef,
182
+ "maxLine": maxLine
183
+ }, other)), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {}))));
184
+ }
185
+ }]);
186
+ }(Component);
128
187
  _defineProperty(RootEllipsis, "displayName", 'Ellipsis');
129
188
  _defineProperty(RootEllipsis, "style", style);
130
189
  _defineProperty(RootEllipsis, "defaultProps", {
@@ -133,99 +192,92 @@ _defineProperty(RootEllipsis, "defaultProps", {
133
192
  includeTooltipProps: defaultTooltipProps,
134
193
  __excludeProps: ['title']
135
194
  });
136
- const EllipsisMiddleContext = /*#__PURE__*/React.createContext(null);
195
+ var EllipsisMiddleContext = /*#__PURE__*/React.createContext(null);
137
196
  function EllipsisMiddle(props) {
138
197
  var _ref5;
139
- const {
140
- styles,
141
- text,
142
- tooltip,
143
- containerRect,
144
- containerRef,
145
- textRef,
146
- tooltipProps,
147
- children,
148
- advanceMode,
149
- tag
150
- } = props;
151
- const resizeElement = React.useRef(null);
152
- const [symbolWidth, setSymbolWidth] = React.useState(0);
153
- const blockWidth = useResizeObserver(resizeElement, containerRect).width;
154
- useEnhancedEffect(() => {
155
- const node = containerRef?.current || resizeElement?.current;
198
+ var styles = props.styles,
199
+ text = props.text,
200
+ tooltip = props.tooltip,
201
+ containerRect = props.containerRect,
202
+ containerRef = props.containerRef,
203
+ textRef = props.textRef,
204
+ tooltipProps = props.tooltipProps,
205
+ children = props.children,
206
+ advanceMode = props.advanceMode,
207
+ tag = props.tag;
208
+ var resizeElement = React.useRef(null);
209
+ var _React$useState = React.useState(0),
210
+ _React$useState2 = _slicedToArray(_React$useState, 2),
211
+ symbolWidth = _React$useState2[0],
212
+ setSymbolWidth = _React$useState2[1];
213
+ var blockWidth = useResizeObserver(resizeElement, containerRect).width;
214
+ useEnhancedEffect(function () {
215
+ var node = (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) || (resizeElement === null || resizeElement === void 0 ? void 0 : resizeElement.current);
156
216
  if (!node) return;
157
- const styleElement = window.getComputedStyle(node);
158
- const dateSpan = document.createElement('temporary-block');
217
+ var styleElement = window.getComputedStyle(node);
218
+ var dateSpan = document.createElement('temporary-block');
159
219
  setFontSettings(dateSpan, styleElement);
160
220
  dateSpan.textContent = 'a';
161
221
  document.body.appendChild(dateSpan);
162
- const rect = dateSpan.getBoundingClientRect();
222
+ var rect = dateSpan.getBoundingClientRect();
163
223
  setSymbolWidth(rect.width);
164
224
  document.body.removeChild(dateSpan);
165
225
  }, []);
166
- const STail = 'span';
167
- const SBeginning = 'span';
168
- const SContainerMiddle = Tooltip;
169
- const SAdvancedModeContainerMiddle = Tooltip;
170
- const displayedSymbols = React.useMemo(() => {
171
- const displayedSymbols = Math.round(blockWidth / symbolWidth);
226
+ var STail = 'span';
227
+ var SBeginning = 'span';
228
+ var SContainerMiddle = Tooltip;
229
+ var SAdvancedModeContainerMiddle = Tooltip;
230
+ var displayedSymbols = React.useMemo(function () {
231
+ var displayedSymbols = Math.round(blockWidth / symbolWidth);
172
232
  return displayedSymbols % 2 === 0 ? displayedSymbols : displayedSymbols - 1;
173
233
  }, [blockWidth, symbolWidth]);
174
- const interaction = text.length > displayedSymbols ? 'hover' : 'none';
175
- const ref = containerRef ?? resizeElement;
176
- const contextValue = React.useMemo(() => ({
177
- begining: text.substring(0, text.length - displayedSymbols / 2 - 1),
178
- tail: text.substring(text.length - displayedSymbols / 2 - 1),
179
- ref
180
- }), [text, displayedSymbols]);
234
+ var interaction = text.length > displayedSymbols ? 'hover' : 'none';
235
+ var ref = containerRef !== null && containerRef !== void 0 ? containerRef : resizeElement;
236
+ var contextValue = React.useMemo(function () {
237
+ return {
238
+ begining: text.substring(0, text.length - displayedSymbols / 2 - 1),
239
+ tail: text.substring(text.length - displayedSymbols / 2 - 1),
240
+ ref: ref
241
+ };
242
+ }, [text, displayedSymbols]);
181
243
  if (advanceMode) {
182
244
  var _ref4;
183
- return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SAdvancedModeContainerMiddle, _ref4.cn("SAdvancedModeContainerMiddle", {
184
- "interaction": tooltip ? interaction : 'none',
185
- ...tooltipProps,
186
- ...forcedAdvancedMode
187
- }), /*#__PURE__*/React.createElement(EllipsisMiddleContext.Provider, {
245
+ return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SAdvancedModeContainerMiddle, _ref4.cn("SAdvancedModeContainerMiddle", _objectSpread(_objectSpread({
246
+ "interaction": tooltip ? interaction : 'none'
247
+ }, tooltipProps), forcedAdvancedMode)), /*#__PURE__*/React.createElement(EllipsisMiddleContext.Provider, {
188
248
  value: contextValue
189
249
  }, children));
190
250
  }
191
- return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SContainerMiddle, _ref5.cn("SContainerMiddle", {
251
+ return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SContainerMiddle, _ref5.cn("SContainerMiddle", _objectSpread({
192
252
  "interaction": tooltip ? interaction : 'none',
193
253
  "title": text,
194
254
  "ref": forkRef(ref, textRef),
195
- "tag": tag,
196
- ...tooltipProps
197
- }), /*#__PURE__*/React.createElement(SBeginning, _ref5.cn("SBeginning", {}), contextValue.begining), /*#__PURE__*/React.createElement(STail, _ref5.cn("STail", {}), contextValue.tail));
255
+ "tag": tag
256
+ }, tooltipProps)), /*#__PURE__*/React.createElement(SBeginning, _ref5.cn("SBeginning", {}), contextValue.begining), /*#__PURE__*/React.createElement(STail, _ref5.cn("STail", {}), contextValue.tail));
198
257
  }
199
- function Content({
200
- styles,
201
- Children
202
- }) {
258
+ function Content(_ref8) {
203
259
  var _ref = arguments[0],
204
260
  _ref7;
205
- const SEllipsis = Tooltip.Trigger;
206
- const ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);
207
- const STail = 'span';
208
- const SBeginning = 'span';
261
+ var styles = _ref8.styles,
262
+ Children = _ref8.Children;
263
+ var SEllipsis = Tooltip.Trigger;
264
+ var ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);
265
+ var STail = 'span';
266
+ var SBeginning = 'span';
209
267
  if (ellipsisMiddleContext) {
210
268
  var _ref6;
211
- const {
212
- begining,
213
- tail,
214
- ref
215
- } = ellipsisMiddleContext;
216
- return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SEllipsis, _ref6.cn("SEllipsis", {
217
- ..._assignProps({
218
- "middle-mod": true,
219
- "ref": ref
220
- }, _ref)
221
- }), /*#__PURE__*/React.createElement(SBeginning, _ref6.cn("SBeginning", {}), begining), /*#__PURE__*/React.createElement(STail, _ref6.cn("STail", {}), tail));
269
+ var begining = ellipsisMiddleContext.begining,
270
+ tail = ellipsisMiddleContext.tail,
271
+ ref = ellipsisMiddleContext.ref;
272
+ return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SEllipsis, _ref6.cn("SEllipsis", _objectSpread({}, _assignProps({
273
+ "middle-mod": true,
274
+ "ref": ref
275
+ }, _ref))), /*#__PURE__*/React.createElement(SBeginning, _ref6.cn("SBeginning", {}), begining), /*#__PURE__*/React.createElement(STail, _ref6.cn("STail", {}), tail));
222
276
  }
223
- return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SEllipsis, _ref7.cn("SEllipsis", {
224
- ..._assignProps2({}, _ref)
225
- }), /*#__PURE__*/React.createElement(Children, _ref7.cn("Children", {})));
277
+ return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SEllipsis, _ref7.cn("SEllipsis", _objectSpread({}, _assignProps2({}, _ref))), /*#__PURE__*/React.createElement(Children, _ref7.cn("Children", {})));
226
278
  }
227
- const Ellipsis = createComponent(RootEllipsis, {
228
- Content,
279
+ var Ellipsis = createComponent(RootEllipsis, {
280
+ Content: Content,
229
281
  Popper: Tooltip.Popper
230
282
  });
231
283
  export default Ellipsis;