@semcore/ellipsis 16.0.12 → 17.0.0-prerelease.17

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.
@@ -1,16 +1,12 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import canUseDOM from '@semcore/core/lib/utils/canUseDOM';
3
2
  import useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';
4
3
  import React from 'react';
5
- export var useResizeObserver = function useResizeObserver(ref, hookOverride) {
6
- var _React$useState = React.useState(0),
7
- _React$useState2 = _slicedToArray(_React$useState, 2),
8
- width = _React$useState2[0],
9
- setWidth = _React$useState2[1];
10
- var handleResize = React.useCallback(function (entries) {
4
+ export const useResizeObserver = (ref, hookOverride) => {
5
+ const [width, setWidth] = React.useState(0);
6
+ const handleResize = React.useCallback(entries => {
11
7
  setWidth(entries[0].contentRect.width);
12
8
  }, []);
13
- useEnhancedEffect(function () {
9
+ useEnhancedEffect(() => {
14
10
  if (!ref.current) {
15
11
  return;
16
12
  }
@@ -18,11 +14,11 @@ export var useResizeObserver = function useResizeObserver(ref, hookOverride) {
18
14
  return;
19
15
  }
20
16
  if (canUseDOM()) {
21
- var ro = new ResizeObserver(function (entries) {
17
+ const ro = new ResizeObserver(entries => {
22
18
  handleResize(entries);
23
19
  });
24
20
  ro.observe(ref.current);
25
- return function () {
21
+ return () => {
26
22
  ro.disconnect();
27
23
  };
28
24
  }
@@ -31,7 +27,7 @@ export var useResizeObserver = function useResizeObserver(ref, hookOverride) {
31
27
  return hookOverride;
32
28
  }
33
29
  return {
34
- width: width
30
+ width
35
31
  };
36
32
  };
37
33
  //# sourceMappingURL=useResizeObserver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResizeObserver.js","names":["canUseDOM","useEnhancedEffect","React","useResizeObserver","ref","hookOverride","_React$useState","useState","_React$useState2","_slicedToArray","width","setWidth","handleResize","useCallback","entries","contentRect","current","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,OAAOA,SAAS,MAAM,mCAAmC;AACzD,OAAOC,iBAAiB,MAAM,+CAA+C;AAC7E,OAAOC,KAAK,MAA0B,OAAO;AAE7C,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAC5BC,GAA2B,EAC3BC,YAAgC,EAC7B;EACH,IAAAC,eAAA,GAA0BJ,KAAK,CAACK,QAAQ,CAAS,CAAC,CAAC;IAAAC,gBAAA,GAAAC,cAAA,CAAAH,eAAA;IAA5CI,KAAK,GAAAF,gBAAA;IAAEG,QAAQ,GAAAH,gBAAA;EAEtB,IAAMI,YAAY,GAAGV,KAAK,CAACW,WAAW,CAAC,UAACC,OAA8B,EAAK;IACzEH,QAAQ,CAACG,OAAO,CAAC,CAAC,CAAC,CAACC,WAAW,CAACL,KAAK,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAENT,iBAAiB,CAAC,YAAM;IACtB,IAAI,CAACG,GAAG,CAACY,OAAO,EAAE;MAChB;IACF;IAEA,IAAIX,YAAY,EAAE;MAChB;IACF;IACA,IAAIL,SAAS,CAAC,CAAC,EAAE;MACf,IAAMiB,EAAE,GAAG,IAAIC,cAAc,CAAC,UAACJ,OAA8B,EAAK;QAChEF,YAAY,CAACE,OAAO,CAAC;MACvB,CAAC,CAAC;MAEFG,EAAE,CAACE,OAAO,CAACf,GAAG,CAACY,OAAO,CAAC;MAEvB,OAAO,YAAM;QACXC,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;IAAEK,KAAK,EAALA;EAAM,CAAC;AAClB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useResizeObserver.js","names":["canUseDOM","useEnhancedEffect","React","useResizeObserver","ref","hookOverride","width","setWidth","useState","handleResize","useCallback","entries","contentRect","current","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,OAAOA,SAAS,MAAM,mCAAmC;AACzD,OAAOC,iBAAiB,MAAM,+CAA+C;AAC7E,OAAOC,KAAK,MAA0B,OAAO;AAE7C,OAAO,MAAMC,iBAAiB,GAAGA,CAC/BC,GAA2B,EAC3BC,YAAgC,KAC7B;EACH,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGL,KAAK,CAACM,QAAQ,CAAS,CAAC,CAAC;EAEnD,MAAMC,YAAY,GAAGP,KAAK,CAACQ,WAAW,CAAEC,OAA8B,IAAK;IACzEJ,QAAQ,CAACI,OAAO,CAAC,CAAC,CAAC,CAACC,WAAW,CAACN,KAAK,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAENL,iBAAiB,CAAC,MAAM;IACtB,IAAI,CAACG,GAAG,CAACS,OAAO,EAAE;MAChB;IACF;IAEA,IAAIR,YAAY,EAAE;MAChB;IACF;IACA,IAAIL,SAAS,CAAC,CAAC,EAAE;MACf,MAAMc,EAAE,GAAG,IAAIC,cAAc,CAAEJ,OAA8B,IAAK;QAChEF,YAAY,CAACE,OAAO,CAAC;MACvB,CAAC,CAAC;MAEFG,EAAE,CAACE,OAAO,CAACZ,GAAG,CAACS,OAAO,CAAC;MAEvB,OAAO,MAAM;QACXC,EAAE,CAACG,UAAU,CAAC,CAAC;MACjB,CAAC;IACH;EACF,CAAC,EAAE,CAACZ,YAAY,CAAC,CAAC;EAElB,IAAIA,YAAY,EAAE;IAChB,OAAOA,YAAY;EACrB;EACA,OAAO;IAAEC;EAAM,CAAC;AAClB,CAAC","ignoreList":[]}
@@ -0,0 +1,47 @@
1
+ export const setFontSettings = (element, styleElement) => {
2
+ element.style.fontFamily = styleElement.getPropertyValue('font-family');
3
+ element.style.fontSize = styleElement.getPropertyValue('font-size');
4
+ element.style.fontWeight = styleElement.getPropertyValue('font-weight');
5
+ element.style.lineHeight = styleElement.getPropertyValue('line-height');
6
+ element.style.fontFeatureSettings = styleElement.getPropertyValue('font-feature-settings');
7
+ element.style.fontVariantNumeric = styleElement.getPropertyValue('font-variant-numeric');
8
+ };
9
+ export function isTextOverflowing(element, multiline, text) {
10
+ if (!element) return false;
11
+ const {
12
+ height: currentHeight,
13
+ width: currentWidth
14
+ } = element.getBoundingClientRect();
15
+ const measuringElement = createMeasurerElement(element, text);
16
+ let isOverflowing = false;
17
+ document.body.appendChild(measuringElement);
18
+ if (multiline) {
19
+ measuringElement.style.width = `${currentWidth}px`;
20
+ const width = measuringElement.scrollWidth;
21
+ const height = measuringElement.getBoundingClientRect().height;
22
+ if (Math.ceil(currentHeight) < height || Math.ceil(currentWidth) < width) {
23
+ isOverflowing = true;
24
+ }
25
+ } else {
26
+ measuringElement.style.whiteSpace = 'nowrap';
27
+ isOverflowing = Math.ceil(currentWidth) < measuringElement.getBoundingClientRect().width;
28
+ }
29
+ document.body.removeChild(measuringElement);
30
+ return isOverflowing;
31
+ }
32
+ function createMeasurerElement(element, text) {
33
+ const styleElement = window.getComputedStyle(element, null);
34
+ const temporaryElement = document.createElement('temporary-block');
35
+ temporaryElement.style.display = styleElement.getPropertyValue('display');
36
+ temporaryElement.style.padding = styleElement.getPropertyValue('padding');
37
+ temporaryElement.style.position = 'absolute';
38
+ temporaryElement.style.right = '0%';
39
+ temporaryElement.style.bottom = '0%';
40
+ temporaryElement.style.visibility = 'hidden';
41
+ temporaryElement.style.whiteSpace = styleElement.getPropertyValue('white-space');
42
+ temporaryElement.style.wordWrap = styleElement.getPropertyValue('word-wrap');
43
+ setFontSettings(temporaryElement, styleElement);
44
+ temporaryElement.textContent = text ?? element.textContent;
45
+ return temporaryElement;
46
+ }
47
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["setFontSettings","element","styleElement","style","fontFamily","getPropertyValue","fontSize","fontWeight","lineHeight","fontFeatureSettings","fontVariantNumeric","isTextOverflowing","multiline","text","height","currentHeight","width","currentWidth","getBoundingClientRect","measuringElement","createMeasurerElement","isOverflowing","document","body","appendChild","scrollWidth","Math","ceil","whiteSpace","removeChild","window","getComputedStyle","temporaryElement","createElement","display","padding","position","right","bottom","visibility","wordWrap","textContent"],"sources":["../../src/utils.ts"],"sourcesContent":["export const setFontSettings = (element: HTMLElement, styleElement: CSSStyleDeclaration): void => {\n element.style.fontFamily = styleElement.getPropertyValue('font-family');\n element.style.fontSize = styleElement.getPropertyValue('font-size');\n element.style.fontWeight = styleElement.getPropertyValue('font-weight');\n element.style.lineHeight = styleElement.getPropertyValue('line-height');\n element.style.fontFeatureSettings =\n styleElement.getPropertyValue('font-feature-settings');\n element.style.fontVariantNumeric = styleElement.getPropertyValue('font-variant-numeric');\n};\n\nexport function isTextOverflowing(element: HTMLElement | null, multiline: boolean, text: string): boolean {\n if (!element) return false;\n\n const { height: currentHeight, width: currentWidth } = element.getBoundingClientRect();\n const measuringElement = createMeasurerElement(element, text);\n let isOverflowing = false;\n\n document.body.appendChild(measuringElement);\n if (multiline) {\n measuringElement.style.width = `${currentWidth}px`;\n\n const width = measuringElement.scrollWidth;\n const height = measuringElement.getBoundingClientRect().height;\n\n if (Math.ceil(currentHeight) < height || Math.ceil(currentWidth) < width) {\n isOverflowing = true;\n }\n } else {\n measuringElement.style.whiteSpace = 'nowrap';\n isOverflowing = Math.ceil(currentWidth) < measuringElement.getBoundingClientRect().width;\n }\n\n document.body.removeChild(measuringElement);\n\n return isOverflowing;\n}\n\nfunction createMeasurerElement(element: HTMLElement, text?: string) {\n const styleElement = window.getComputedStyle(element, null);\n const temporaryElement = document.createElement('temporary-block');\n temporaryElement.style.display = styleElement.getPropertyValue('display');\n temporaryElement.style.padding = styleElement.getPropertyValue('padding');\n temporaryElement.style.position = 'absolute';\n temporaryElement.style.right = '0%';\n temporaryElement.style.bottom = '0%';\n temporaryElement.style.visibility = 'hidden';\n temporaryElement.style.whiteSpace = styleElement.getPropertyValue('white-space');\n temporaryElement.style.wordWrap = styleElement.getPropertyValue('word-wrap');\n\n setFontSettings(temporaryElement, styleElement);\n\n temporaryElement.textContent = text ?? element.textContent;\n return temporaryElement;\n}\n"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAGA,CAACC,OAAoB,EAAEC,YAAiC,KAAW;EAChGD,OAAO,CAACE,KAAK,CAACC,UAAU,GAAGF,YAAY,CAACG,gBAAgB,CAAC,aAAa,CAAC;EACvEJ,OAAO,CAACE,KAAK,CAACG,QAAQ,GAAGJ,YAAY,CAACG,gBAAgB,CAAC,WAAW,CAAC;EACnEJ,OAAO,CAACE,KAAK,CAACI,UAAU,GAAGL,YAAY,CAACG,gBAAgB,CAAC,aAAa,CAAC;EACvEJ,OAAO,CAACE,KAAK,CAACK,UAAU,GAAGN,YAAY,CAACG,gBAAgB,CAAC,aAAa,CAAC;EACvEJ,OAAO,CAACE,KAAK,CAACM,mBAAmB,GAC/BP,YAAY,CAACG,gBAAgB,CAAC,uBAAuB,CAAC;EACxDJ,OAAO,CAACE,KAAK,CAACO,kBAAkB,GAAGR,YAAY,CAACG,gBAAgB,CAAC,sBAAsB,CAAC;AAC1F,CAAC;AAED,OAAO,SAASM,iBAAiBA,CAACV,OAA2B,EAAEW,SAAkB,EAAEC,IAAY,EAAW;EACxG,IAAI,CAACZ,OAAO,EAAE,OAAO,KAAK;EAE1B,MAAM;IAAEa,MAAM,EAAEC,aAAa;IAAEC,KAAK,EAAEC;EAAa,CAAC,GAAGhB,OAAO,CAACiB,qBAAqB,CAAC,CAAC;EACtF,MAAMC,gBAAgB,GAAGC,qBAAqB,CAACnB,OAAO,EAAEY,IAAI,CAAC;EAC7D,IAAIQ,aAAa,GAAG,KAAK;EAEzBC,QAAQ,CAACC,IAAI,CAACC,WAAW,CAACL,gBAAgB,CAAC;EAC3C,IAAIP,SAAS,EAAE;IACbO,gBAAgB,CAAChB,KAAK,CAACa,KAAK,GAAG,GAAGC,YAAY,IAAI;IAElD,MAAMD,KAAK,GAAGG,gBAAgB,CAACM,WAAW;IAC1C,MAAMX,MAAM,GAAGK,gBAAgB,CAACD,qBAAqB,CAAC,CAAC,CAACJ,MAAM;IAE9D,IAAIY,IAAI,CAACC,IAAI,CAACZ,aAAa,CAAC,GAAGD,MAAM,IAAIY,IAAI,CAACC,IAAI,CAACV,YAAY,CAAC,GAAGD,KAAK,EAAE;MACxEK,aAAa,GAAG,IAAI;IACtB;EACF,CAAC,MAAM;IACLF,gBAAgB,CAAChB,KAAK,CAACyB,UAAU,GAAG,QAAQ;IAC5CP,aAAa,GAAGK,IAAI,CAACC,IAAI,CAACV,YAAY,CAAC,GAAGE,gBAAgB,CAACD,qBAAqB,CAAC,CAAC,CAACF,KAAK;EAC1F;EAEAM,QAAQ,CAACC,IAAI,CAACM,WAAW,CAACV,gBAAgB,CAAC;EAE3C,OAAOE,aAAa;AACtB;AAEA,SAASD,qBAAqBA,CAACnB,OAAoB,EAAEY,IAAa,EAAE;EAClE,MAAMX,YAAY,GAAG4B,MAAM,CAACC,gBAAgB,CAAC9B,OAAO,EAAE,IAAI,CAAC;EAC3D,MAAM+B,gBAAgB,GAAGV,QAAQ,CAACW,aAAa,CAAC,iBAAiB,CAAC;EAClED,gBAAgB,CAAC7B,KAAK,CAAC+B,OAAO,GAAGhC,YAAY,CAACG,gBAAgB,CAAC,SAAS,CAAC;EACzE2B,gBAAgB,CAAC7B,KAAK,CAACgC,OAAO,GAAGjC,YAAY,CAACG,gBAAgB,CAAC,SAAS,CAAC;EACzE2B,gBAAgB,CAAC7B,KAAK,CAACiC,QAAQ,GAAG,UAAU;EAC5CJ,gBAAgB,CAAC7B,KAAK,CAACkC,KAAK,GAAG,IAAI;EACnCL,gBAAgB,CAAC7B,KAAK,CAACmC,MAAM,GAAG,IAAI;EACpCN,gBAAgB,CAAC7B,KAAK,CAACoC,UAAU,GAAG,QAAQ;EAC5CP,gBAAgB,CAAC7B,KAAK,CAACyB,UAAU,GAAG1B,YAAY,CAACG,gBAAgB,CAAC,aAAa,CAAC;EAChF2B,gBAAgB,CAAC7B,KAAK,CAACqC,QAAQ,GAAGtC,YAAY,CAACG,gBAAgB,CAAC,WAAW,CAAC;EAE5EL,eAAe,CAACgC,gBAAgB,EAAE9B,YAAY,CAAC;EAE/C8B,gBAAgB,CAACS,WAAW,GAAG5B,IAAI,IAAIZ,OAAO,CAACwC,WAAW;EAC1D,OAAOT,gBAAgB;AACzB","ignoreList":[]}
@@ -1,12 +1,6 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/esm/createClass";
6
- import _callSuper from "@babel/runtime/helpers/esm/callSuper";
7
- import _inherits from "@babel/runtime/helpers/esm/inherits";
8
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
- import { createComponent, sstyled, Component, assignProps } from "@semcore/core";
2
+ import { createComponent, Component, sstyled, assignProps } from "@semcore/core";
3
+ import { Box } from "@semcore/base-components";
10
4
  import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
11
5
  import findComponent, { isAdvanceMode } from "@semcore/core/lib/utils/findComponent";
12
6
  import getOriginChildren from "@semcore/core/lib/utils/getOriginChildren";
@@ -14,165 +8,127 @@ import pick from "@semcore/core/lib/utils/pick";
14
8
  import reactToText from "@semcore/core/lib/utils/reactToText";
15
9
  import { forkRef } from "@semcore/core/lib/utils/ref";
16
10
  import useEnhancedEffect from "@semcore/core/lib/utils/use/useEnhancedEffect";
17
- import { Box } from "@semcore/flex-box";
18
11
  import Tooltip from "@semcore/tooltip";
19
12
  import React from "react";
20
13
  import { useResizeObserver } from "./useResizeObserver.mjs";
21
- var _excluded = ["styles", "Children", "maxLine", "tooltip", "trim", "containerRect", "containerRef", "includeTooltipProps", "children"];
14
+ import { isTextOverflowing, setFontSettings } from "./utils.mjs";
22
15
  /*!__reshadow-styles__:"./style/ellipsis.shadow.css"*/
23
- var style = (
16
+ const style = (
24
17
  /*__reshadow_css_start__*/
25
18
  (sstyled.insert(
26
19
  /*__inner_css_start__*/
27
- ".___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}",
20
+ ".___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}",
28
21
  /*__inner_css_end__*/
29
- "4aonj_gg_"
22
+ "1x34o_gg_"
30
23
  ), /*__reshadow_css_end__*/
31
24
  {
32
- "__SBeginning": "___SBeginning_4aonj_gg_",
33
- "__SEllipsis": "___SEllipsis_4aonj_gg_",
34
- "__SContainer": "___SContainer_4aonj_gg_",
35
- "__SNoTooltipContainer": "___SNoTooltipContainer_4aonj_gg_",
36
- "__SContainerMiddle": "___SContainerMiddle_4aonj_gg_",
37
- "_maxLine": "__maxLine_4aonj_gg_",
38
- "--maxLine": "--maxLine_4aonj",
39
- "_middle-mod": "__middle-mod_4aonj_gg_",
40
- "__STail": "___STail_4aonj_gg_"
25
+ "__SBeginning": "___SBeginning_1x34o_gg_",
26
+ "__SEllipsis": "___SEllipsis_1x34o_gg_",
27
+ "__SContainer": "___SContainer_1x34o_gg_",
28
+ "__SNoTooltipContainer": "___SNoTooltipContainer_1x34o_gg_",
29
+ "__SContainerMiddle": "___SContainerMiddle_1x34o_gg_",
30
+ "_maxLine": "__maxLine_1x34o_gg_",
31
+ "--maxLine": "--maxLine_1x34o",
32
+ "_middle-mod": "__middle-mod_1x34o_gg_",
33
+ "__STail": "___STail_1x34o_gg_"
41
34
  })
42
35
  );
43
- var defaultTooltipProps = ["title", "theme", "strategy", "modifiers", "placement", "interaction", "timeout", "visible", "defaultVisible", "onVisibleChange", "offset", "preventOverflow", "arrow", "flip", "computeStyles", "eventListeners", "onFirstUpdate", "cursorAnchoring"];
44
- var setFontSettings = function setFontSettings2(element, styleElement) {
45
- element.style.fontFamily = styleElement.getPropertyValue("font-family");
46
- element.style.fontSize = styleElement.getPropertyValue("font-size");
47
- element.style.fontWeight = styleElement.getPropertyValue("font-weight");
48
- element.style.lineHeight = styleElement.getPropertyValue("line-height");
49
- element.style.fontFeatureSettings = styleElement.getPropertyValue("font-feature-settings");
50
- element.style.fontVariantNumeric = styleElement.getPropertyValue("font-variant-numeric");
51
- };
52
- var createMeasurerElement = function createMeasurerElement2(element, text) {
53
- var styleElement = window.getComputedStyle(element, null);
54
- var temporaryElement = document.createElement("temporary-block");
55
- temporaryElement.style.display = styleElement.getPropertyValue("display");
56
- temporaryElement.style.padding = styleElement.getPropertyValue("padding");
57
- temporaryElement.style.position = "absolute";
58
- temporaryElement.style.right = "0%";
59
- temporaryElement.style.bottom = "0%";
60
- temporaryElement.style.visibility = "hidden";
61
- temporaryElement.style.whiteSpace = styleElement.getPropertyValue("white-space");
62
- temporaryElement.style.wordWrap = styleElement.getPropertyValue("word-wrap");
63
- setFontSettings(temporaryElement, styleElement);
64
- temporaryElement.textContent = text !== null && text !== void 0 ? text : element.textContent;
65
- return temporaryElement;
66
- };
67
- function isTextOverflowing(element, multiline, text) {
68
- if (!element) return false;
69
- var _element$getBoundingC = element.getBoundingClientRect(), currentHeight = _element$getBoundingC.height, currentWidth = _element$getBoundingC.width;
70
- var measuringElement = createMeasurerElement(element, text);
71
- var isOverflowing = false;
72
- document.body.appendChild(measuringElement);
73
- if (multiline) {
74
- measuringElement.style.width = "".concat(currentWidth, "px");
75
- var width = measuringElement.scrollWidth;
76
- var height = measuringElement.getBoundingClientRect().height;
77
- if (Math.ceil(currentHeight) < height || Math.ceil(currentWidth) < width) {
78
- isOverflowing = true;
79
- }
80
- } else {
81
- measuringElement.style.whiteSpace = "nowrap";
82
- isOverflowing = Math.ceil(currentWidth) < measuringElement.getBoundingClientRect().width;
83
- }
84
- document.body.removeChild(measuringElement);
85
- return isOverflowing;
86
- }
87
- var forcedAdvancedMode = {
36
+ const defaultTooltipProps = ["title", "theme", "strategy", "modifiers", "placement", "interaction", "timeout", "visible", "defaultVisible", "onVisibleChange", "offset", "preventOverflow", "arrow", "flip", "computeStyles", "eventListeners", "onFirstUpdate", "cursorAnchoring"];
37
+ const forcedAdvancedMode = {
88
38
  forcedAdvancedMode: true
89
39
  };
90
- var noAdvancedMode = {};
91
- var RootEllipsis = /* @__PURE__ */ (function(_Component) {
92
- function RootEllipsis2() {
93
- var _this;
94
- _classCallCheck(this, RootEllipsis2);
95
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
96
- args[_key] = arguments[_key];
97
- }
98
- _this = _callSuper(this, RootEllipsis2, [].concat(args));
99
- _defineProperty(_this, "state", {
40
+ const noAdvancedMode = {};
41
+ class RootEllipsis extends Component {
42
+ constructor(...args) {
43
+ super(...args);
44
+ _defineProperty(this, "state", {
100
45
  visible: false
101
46
  });
102
- _defineProperty(_this, "textRef", /* @__PURE__ */ React.createRef());
103
- _defineProperty(_this, "handlerVisibleChange", function(visible) {
104
- _this.setState({
105
- visible: visible && _this.showTooltip()
47
+ _defineProperty(this, "textRef", /* @__PURE__ */ React.createRef());
48
+ _defineProperty(this, "handlerVisibleChange", (visible) => {
49
+ this.setState({
50
+ visible: visible && this.showTooltip()
106
51
  });
107
52
  });
108
- return _this;
109
53
  }
110
- _inherits(RootEllipsis2, _Component);
111
- return _createClass(RootEllipsis2, [{
112
- key: "showTooltip",
113
- value: function showTooltip() {
114
- var _this$asProps = this.asProps, _this$asProps$maxLine = _this$asProps.maxLine, maxLine = _this$asProps$maxLine === void 0 ? 1 : _this$asProps$maxLine, Children = _this$asProps.Children;
115
- var text = reactToText(getOriginChildren(Children));
116
- return isTextOverflowing(this.textRef.current, maxLine > 1, text);
117
- }
118
- }, {
119
- key: "getContentProps",
120
- value: function getContentProps() {
121
- return {
122
- ref: this.textRef,
123
- maxLine: this.asProps.maxLine
124
- };
125
- }
126
- }, {
127
- key: "getPopperProps",
128
- value: function getPopperProps() {
129
- var _this$asProps2 = this.asProps, Children = _this$asProps2.Children, includeTooltipProps = _this$asProps2.includeTooltipProps;
130
- var text = reactToText(getOriginChildren(Children));
131
- var tooltipProps = pick(this.asProps, includeTooltipProps);
132
- return _objectSpread({
133
- children: text
134
- }, tooltipProps);
135
- }
136
- }, {
137
- key: "render",
138
- value: function render() {
139
- var _ref3, _tooltipProps$visible;
140
- var SEllipsis = this.Root;
141
- var SContainer = Tooltip;
142
- var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, Children = _this$asProps3.Children, maxLine = _this$asProps3.maxLine, tooltip = _this$asProps3.tooltip, trim = _this$asProps3.trim, containerRect = _this$asProps3.containerRect, containerRef = _this$asProps3.containerRef, includeTooltipProps = _this$asProps3.includeTooltipProps;
143
- _this$asProps3.children;
144
- var other = _objectWithoutProperties(_this$asProps3, _excluded);
145
- var visible = this.state.visible;
146
- var advancedContent = findComponent(Children, [Ellipsis.Content.displayName]);
147
- var text = reactToText(advancedContent || getOriginChildren(Children));
148
- var advanceMode = isAdvanceMode(Children, [Ellipsis.Content.displayName, Ellipsis.Popper.displayName]);
149
- var tooltipProps = pick(this.asProps, includeTooltipProps);
150
- tooltipProps.visible = (_tooltipProps$visible = tooltipProps.visible) !== null && _tooltipProps$visible !== void 0 ? _tooltipProps$visible : visible;
151
- tooltipProps.onVisibleChange = tooltipProps.onVisibleChange ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange) : this.handlerVisibleChange;
152
- if (trim === "middle") {
153
- var _ref2;
154
- return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(EllipsisMiddle, _ref2.cn("EllipsisMiddle", _objectSpread({
155
- "text": text,
156
- "styles": styles,
157
- "tooltip": tooltip,
158
- "containerRect": containerRect,
159
- "containerRef": containerRef,
160
- "textRef": this.textRef,
161
- "tooltipProps": tooltipProps,
162
- "advanceMode": advanceMode
163
- }, other)), /* @__PURE__ */ React.createElement(Children, _ref2.cn("Children", {})));
164
- }
165
- return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SContainer, _ref3.cn("SContainer", _objectSpread(_objectSpread({
166
- "interaction": tooltip ? "hover" : "none",
167
- "title": !advanceMode ? text : void 0
168
- }, tooltipProps), advanceMode ? forcedAdvancedMode : noAdvancedMode)), advanceMode ? /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {})) : /* @__PURE__ */ React.createElement(SEllipsis, _ref3.cn("SEllipsis", _objectSpread({
169
- "render": Box,
170
- "ref": this.textRef,
171
- "maxLine": maxLine
172
- }, other)), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {}))));
54
+ showTooltip() {
55
+ const {
56
+ maxLine = 1,
57
+ Children
58
+ } = this.asProps;
59
+ const text = reactToText(getOriginChildren(Children));
60
+ return isTextOverflowing(this.textRef.current, maxLine > 1, text);
61
+ }
62
+ getContentProps() {
63
+ return {
64
+ ref: this.textRef,
65
+ maxLine: this.asProps.maxLine
66
+ };
67
+ }
68
+ getPopperProps() {
69
+ const {
70
+ Children,
71
+ includeTooltipProps
72
+ } = this.asProps;
73
+ const text = reactToText(getOriginChildren(Children));
74
+ const tooltipProps = pick(this.asProps, includeTooltipProps);
75
+ return {
76
+ children: text,
77
+ ...tooltipProps
78
+ };
79
+ }
80
+ render() {
81
+ var _ref3;
82
+ const SEllipsis = this.Root;
83
+ const SContainer = Tooltip;
84
+ const {
85
+ styles,
86
+ Children,
87
+ maxLine,
88
+ tooltip,
89
+ trim,
90
+ containerRect,
91
+ containerRef,
92
+ includeTooltipProps,
93
+ children: _children,
94
+ ...other
95
+ } = this.asProps;
96
+ const {
97
+ visible
98
+ } = this.state;
99
+ const advancedContent = findComponent(Children, [Ellipsis.Content.displayName]);
100
+ const text = reactToText(advancedContent || getOriginChildren(Children));
101
+ const advanceMode = isAdvanceMode(Children, [Ellipsis.Content.displayName, Ellipsis.Popper.displayName]);
102
+ const tooltipProps = pick(this.asProps, includeTooltipProps);
103
+ tooltipProps.visible = tooltipProps.visible ?? visible;
104
+ tooltipProps.onVisibleChange = tooltipProps.onVisibleChange ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange) : this.handlerVisibleChange;
105
+ if (trim === "middle") {
106
+ var _ref2;
107
+ return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(EllipsisMiddle, _ref2.cn("EllipsisMiddle", {
108
+ "text": text,
109
+ "styles": styles,
110
+ "tooltip": tooltip,
111
+ "containerRect": containerRect,
112
+ "containerRef": containerRef,
113
+ "textRef": this.textRef,
114
+ "tooltipProps": tooltipProps,
115
+ "advanceMode": advanceMode,
116
+ ...other
117
+ }), /* @__PURE__ */ React.createElement(Children, _ref2.cn("Children", {})));
173
118
  }
174
- }]);
175
- })(Component);
119
+ return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SContainer, _ref3.cn("SContainer", {
120
+ "interaction": tooltip ? "hover" : "none",
121
+ "title": !advanceMode ? text : void 0,
122
+ ...tooltipProps,
123
+ ...advanceMode ? forcedAdvancedMode : noAdvancedMode
124
+ }), advanceMode ? /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {})) : /* @__PURE__ */ React.createElement(SEllipsis, _ref3.cn("SEllipsis", {
125
+ "render": Box,
126
+ "ref": this.textRef,
127
+ "maxLine": maxLine,
128
+ ...other
129
+ }), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {}))));
130
+ }
131
+ }
176
132
  _defineProperty(RootEllipsis, "displayName", "Ellipsis");
177
133
  _defineProperty(RootEllipsis, "style", style);
178
134
  _defineProperty(RootEllipsis, "defaultProps", {
@@ -181,75 +137,97 @@ _defineProperty(RootEllipsis, "defaultProps", {
181
137
  includeTooltipProps: defaultTooltipProps,
182
138
  __excludeProps: ["title"]
183
139
  });
184
- var EllipsisMiddleContext = /* @__PURE__ */ React.createContext(null);
185
- var EllipsisMiddle = function EllipsisMiddle2(props) {
140
+ const EllipsisMiddleContext = /* @__PURE__ */ React.createContext(null);
141
+ function EllipsisMiddle(props) {
186
142
  var _ref5;
187
- var styles = props.styles, text = props.text, tooltip = props.tooltip, containerRect = props.containerRect, containerRef = props.containerRef, textRef = props.textRef, tooltipProps = props.tooltipProps, children = props.children, advanceMode = props.advanceMode, tag = props.tag;
188
- var resizeElement = React.useRef(null);
189
- var _React$useState = React.useState(0), _React$useState2 = _slicedToArray(_React$useState, 2), symbolWidth = _React$useState2[0], setSymbolWidth = _React$useState2[1];
190
- var blockWidth = useResizeObserver(resizeElement, containerRect).width;
191
- useEnhancedEffect(function() {
192
- var node = (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) || (resizeElement === null || resizeElement === void 0 ? void 0 : resizeElement.current);
143
+ const {
144
+ styles,
145
+ text,
146
+ tooltip,
147
+ containerRect,
148
+ containerRef,
149
+ textRef,
150
+ tooltipProps,
151
+ children,
152
+ advanceMode,
153
+ tag
154
+ } = props;
155
+ const resizeElement = React.useRef(null);
156
+ const [symbolWidth, setSymbolWidth] = React.useState(0);
157
+ const blockWidth = useResizeObserver(resizeElement, containerRect).width;
158
+ useEnhancedEffect(() => {
159
+ const node = (containerRef == null ? void 0 : containerRef.current) || (resizeElement == null ? void 0 : resizeElement.current);
193
160
  if (!node) return;
194
- var styleElement = window.getComputedStyle(node);
195
- var dateSpan = document.createElement("temporary-block");
161
+ const styleElement = window.getComputedStyle(node);
162
+ const dateSpan = document.createElement("temporary-block");
196
163
  setFontSettings(dateSpan, styleElement);
197
164
  dateSpan.textContent = "a";
198
165
  document.body.appendChild(dateSpan);
199
- var rect = dateSpan.getBoundingClientRect();
166
+ const rect = dateSpan.getBoundingClientRect();
200
167
  setSymbolWidth(rect.width);
201
168
  document.body.removeChild(dateSpan);
202
169
  }, []);
203
- var STail = "span";
204
- var SBeginning = "span";
205
- var SContainerMiddle = Tooltip;
206
- var SAdvancedModeContainerMiddle = Tooltip;
207
- var displayedSymbols = React.useMemo(function() {
208
- var displayedSymbols2 = Math.round(blockWidth / symbolWidth);
170
+ const STail = "span";
171
+ const SBeginning = "span";
172
+ const SContainerMiddle = Tooltip;
173
+ const SAdvancedModeContainerMiddle = Tooltip;
174
+ const displayedSymbols = React.useMemo(() => {
175
+ const displayedSymbols2 = Math.round(blockWidth / symbolWidth);
209
176
  return displayedSymbols2 % 2 === 0 ? displayedSymbols2 : displayedSymbols2 - 1;
210
177
  }, [blockWidth, symbolWidth]);
211
- var interaction = text.length > displayedSymbols ? "hover" : "none";
212
- var ref = containerRef !== null && containerRef !== void 0 ? containerRef : resizeElement;
213
- var contextValue = React.useMemo(function() {
214
- return {
215
- begining: text.substring(0, text.length - displayedSymbols / 2 - 1),
216
- tail: text.substring(text.length - displayedSymbols / 2 - 1),
217
- ref
218
- };
219
- }, [text, displayedSymbols]);
178
+ const interaction = text.length > displayedSymbols ? "hover" : "none";
179
+ const ref = containerRef ?? resizeElement;
180
+ const contextValue = React.useMemo(() => ({
181
+ begining: text.substring(0, text.length - displayedSymbols / 2 - 1),
182
+ tail: text.substring(text.length - displayedSymbols / 2 - 1),
183
+ ref
184
+ }), [text, displayedSymbols]);
220
185
  if (advanceMode) {
221
186
  var _ref4;
222
- return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SAdvancedModeContainerMiddle, _ref4.cn("SAdvancedModeContainerMiddle", _objectSpread(_objectSpread({
223
- "interaction": tooltip ? interaction : "none"
224
- }, tooltipProps), forcedAdvancedMode)), /* @__PURE__ */ React.createElement(EllipsisMiddleContext.Provider, {
187
+ return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SAdvancedModeContainerMiddle, _ref4.cn("SAdvancedModeContainerMiddle", {
188
+ "interaction": tooltip ? interaction : "none",
189
+ ...tooltipProps,
190
+ ...forcedAdvancedMode
191
+ }), /* @__PURE__ */ React.createElement(EllipsisMiddleContext.Provider, {
225
192
  value: contextValue
226
193
  }, children));
227
194
  }
228
- return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SContainerMiddle, _ref5.cn("SContainerMiddle", _objectSpread({
195
+ return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SContainerMiddle, _ref5.cn("SContainerMiddle", {
229
196
  "interaction": tooltip ? interaction : "none",
230
197
  "title": text,
231
198
  "ref": forkRef(ref, textRef),
232
- "tag": tag
233
- }, tooltipProps)), /* @__PURE__ */ React.createElement(SBeginning, _ref5.cn("SBeginning", {}), contextValue.begining), /* @__PURE__ */ React.createElement(STail, _ref5.cn("STail", {}), contextValue.tail));
234
- };
235
- var Content = function Content2(_ref8) {
199
+ "tag": tag,
200
+ ...tooltipProps
201
+ }), /* @__PURE__ */ React.createElement(SBeginning, _ref5.cn("SBeginning", {}), contextValue.begining), /* @__PURE__ */ React.createElement(STail, _ref5.cn("STail", {}), contextValue.tail));
202
+ }
203
+ function Content({
204
+ styles,
205
+ Children
206
+ }) {
236
207
  var _ref = arguments[0], _ref7;
237
- var styles = _ref8.styles, Children = _ref8.Children;
238
- var SEllipsis = Tooltip.Trigger;
239
- var ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);
240
- var STail = "span";
241
- var SBeginning = "span";
208
+ const SEllipsis = Tooltip.Trigger;
209
+ const ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);
210
+ const STail = "span";
211
+ const SBeginning = "span";
242
212
  if (ellipsisMiddleContext) {
243
213
  var _ref6;
244
- var begining = ellipsisMiddleContext.begining, tail = ellipsisMiddleContext.tail, ref = ellipsisMiddleContext.ref;
245
- return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SEllipsis, _ref6.cn("SEllipsis", _objectSpread({}, assignProps({
246
- "middle-mod": true,
247
- "ref": ref
248
- }, _ref))), /* @__PURE__ */ React.createElement(SBeginning, _ref6.cn("SBeginning", {}), begining), /* @__PURE__ */ React.createElement(STail, _ref6.cn("STail", {}), tail));
214
+ const {
215
+ begining,
216
+ tail,
217
+ ref
218
+ } = ellipsisMiddleContext;
219
+ return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SEllipsis, _ref6.cn("SEllipsis", {
220
+ ...assignProps({
221
+ "middle-mod": true,
222
+ "ref": ref
223
+ }, _ref)
224
+ }), /* @__PURE__ */ React.createElement(SBeginning, _ref6.cn("SBeginning", {}), begining), /* @__PURE__ */ React.createElement(STail, _ref6.cn("STail", {}), tail));
249
225
  }
250
- return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SEllipsis, _ref7.cn("SEllipsis", _objectSpread({}, assignProps({}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref7.cn("Children", {})));
251
- };
252
- var Ellipsis = createComponent(RootEllipsis, {
226
+ return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SEllipsis, _ref7.cn("SEllipsis", {
227
+ ...assignProps({}, _ref)
228
+ }), /* @__PURE__ */ React.createElement(Children, _ref7.cn("Children", {})));
229
+ }
230
+ const Ellipsis = createComponent(RootEllipsis, {
253
231
  Content,
254
232
  Popper: Tooltip.Popper
255
233
  });
@@ -1,13 +1,12 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
3
2
  import useEnhancedEffect from "@semcore/core/lib/utils/use/useEnhancedEffect";
4
3
  import React from "react";
5
- var useResizeObserver = function useResizeObserver2(ref, hookOverride) {
6
- var _React$useState = React.useState(0), _React$useState2 = _slicedToArray(_React$useState, 2), width = _React$useState2[0], setWidth = _React$useState2[1];
7
- var handleResize = React.useCallback(function(entries) {
4
+ const useResizeObserver = (ref, hookOverride) => {
5
+ const [width, setWidth] = React.useState(0);
6
+ const handleResize = React.useCallback((entries) => {
8
7
  setWidth(entries[0].contentRect.width);
9
8
  }, []);
10
- useEnhancedEffect(function() {
9
+ useEnhancedEffect(() => {
11
10
  if (!ref.current) {
12
11
  return;
13
12
  }
@@ -15,11 +14,11 @@ var useResizeObserver = function useResizeObserver2(ref, hookOverride) {
15
14
  return;
16
15
  }
17
16
  if (canUseDOM()) {
18
- var ro = new ResizeObserver(function(entries) {
17
+ const ro = new ResizeObserver((entries) => {
19
18
  handleResize(entries);
20
19
  });
21
20
  ro.observe(ref.current);
22
- return function() {
21
+ return () => {
23
22
  ro.disconnect();
24
23
  };
25
24
  }
@@ -0,0 +1,50 @@
1
+ const setFontSettings = (element, styleElement) => {
2
+ element.style.fontFamily = styleElement.getPropertyValue("font-family");
3
+ element.style.fontSize = styleElement.getPropertyValue("font-size");
4
+ element.style.fontWeight = styleElement.getPropertyValue("font-weight");
5
+ element.style.lineHeight = styleElement.getPropertyValue("line-height");
6
+ element.style.fontFeatureSettings = styleElement.getPropertyValue("font-feature-settings");
7
+ element.style.fontVariantNumeric = styleElement.getPropertyValue("font-variant-numeric");
8
+ };
9
+ function isTextOverflowing(element, multiline, text) {
10
+ if (!element) return false;
11
+ const {
12
+ height: currentHeight,
13
+ width: currentWidth
14
+ } = element.getBoundingClientRect();
15
+ const measuringElement = createMeasurerElement(element, text);
16
+ let isOverflowing = false;
17
+ document.body.appendChild(measuringElement);
18
+ if (multiline) {
19
+ measuringElement.style.width = `${currentWidth}px`;
20
+ const width = measuringElement.scrollWidth;
21
+ const height = measuringElement.getBoundingClientRect().height;
22
+ if (Math.ceil(currentHeight) < height || Math.ceil(currentWidth) < width) {
23
+ isOverflowing = true;
24
+ }
25
+ } else {
26
+ measuringElement.style.whiteSpace = "nowrap";
27
+ isOverflowing = Math.ceil(currentWidth) < measuringElement.getBoundingClientRect().width;
28
+ }
29
+ document.body.removeChild(measuringElement);
30
+ return isOverflowing;
31
+ }
32
+ function createMeasurerElement(element, text) {
33
+ const styleElement = window.getComputedStyle(element, null);
34
+ const temporaryElement = document.createElement("temporary-block");
35
+ temporaryElement.style.display = styleElement.getPropertyValue("display");
36
+ temporaryElement.style.padding = styleElement.getPropertyValue("padding");
37
+ temporaryElement.style.position = "absolute";
38
+ temporaryElement.style.right = "0%";
39
+ temporaryElement.style.bottom = "0%";
40
+ temporaryElement.style.visibility = "hidden";
41
+ temporaryElement.style.whiteSpace = styleElement.getPropertyValue("white-space");
42
+ temporaryElement.style.wordWrap = styleElement.getPropertyValue("word-wrap");
43
+ setFontSettings(temporaryElement, styleElement);
44
+ temporaryElement.textContent = text ?? element.textContent;
45
+ return temporaryElement;
46
+ }
47
+ export {
48
+ isTextOverflowing,
49
+ setFontSettings
50
+ };