@semcore/ellipsis 17.2.1 → 17.2.2-prerelease.11

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,13 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [17.2.2] - 2026-09-10
6
+
7
+ ### Changed
8
+
9
+ - Refactor component types. Deprecated atomic types. Atomic types are
10
+ part of `NSEllipsis` namespace.
11
+
5
12
  ## [17.2.1] - 2026-06-26
6
13
 
7
14
  ### Fixed
@@ -21,18 +21,18 @@ var _react = _interopRequireDefault(require("react"));
21
21
  var _useResizeObserver = require("./useResizeObserver");
22
22
  var _utils = require("./utils");
23
23
  /*!__reshadow-styles__:"./style/ellipsis.shadow.css"*/
24
- const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBeginning_1q1qt_gg_,.___SEllipsis_1q1qt_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SContainerMiddle_1q1qt_gg_,.___SContainer_1q1qt_gg_,.___SNoTooltipContainer_1q1qt_gg_{display:flex;overflow:hidden}.___SEllipsis_1q1qt_gg_.__maxLine_1q1qt_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_1q1qt);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SEllipsis_1q1qt_gg_.__middle-mod_1q1qt_gg_{display:flex;overflow:hidden}.___SContainerMiddle_1q1qt_gg_>:has(.___SBeginning_1q1qt_gg_),.___SContainerMiddle_1q1qt_gg_>:has(.___STail_1q1qt_gg_){display:flex;width:100%}.___STail_1q1qt_gg_{white-space:pre}", /*__inner_css_end__*/"1q1qt_gg_"),
24
+ const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBeginning_o4oo8_gg_,.___SEllipsis_o4oo8_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SContainerMiddle_o4oo8_gg_,.___SContainer_o4oo8_gg_,.___SNoTooltipContainer_o4oo8_gg_{display:flex;overflow:hidden}.___SEllipsis_o4oo8_gg_.__maxLine_o4oo8_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_o4oo8);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SEllipsis_o4oo8_gg_.__middle-mod_o4oo8_gg_{display:flex;overflow:hidden}.___SContainerMiddle_o4oo8_gg_>:has(.___SBeginning_o4oo8_gg_),.___SContainerMiddle_o4oo8_gg_>:has(.___STail_o4oo8_gg_){display:flex;width:100%}.___STail_o4oo8_gg_{white-space:pre}", /*__inner_css_end__*/"o4oo8_gg_"),
25
25
  /*__reshadow_css_end__*/
26
26
  {
27
- "__SBeginning": "___SBeginning_1q1qt_gg_",
28
- "__SEllipsis": "___SEllipsis_1q1qt_gg_",
29
- "__SContainer": "___SContainer_1q1qt_gg_",
30
- "__SNoTooltipContainer": "___SNoTooltipContainer_1q1qt_gg_",
31
- "__SContainerMiddle": "___SContainerMiddle_1q1qt_gg_",
32
- "_maxLine": "__maxLine_1q1qt_gg_",
33
- "--maxLine": "--maxLine_1q1qt",
34
- "_middle-mod": "__middle-mod_1q1qt_gg_",
35
- "__STail": "___STail_1q1qt_gg_"
27
+ "__SBeginning": "___SBeginning_o4oo8_gg_",
28
+ "__SEllipsis": "___SEllipsis_o4oo8_gg_",
29
+ "__SContainer": "___SContainer_o4oo8_gg_",
30
+ "__SNoTooltipContainer": "___SNoTooltipContainer_o4oo8_gg_",
31
+ "__SContainerMiddle": "___SContainerMiddle_o4oo8_gg_",
32
+ "_maxLine": "__maxLine_o4oo8_gg_",
33
+ "--maxLine": "--maxLine_o4oo8",
34
+ "_middle-mod": "__middle-mod_o4oo8_gg_",
35
+ "__STail": "___STail_o4oo8_gg_"
36
36
  });
37
37
  const defaultTooltipProps = ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate', 'cursorAnchoring'];
38
38
  const forcedAdvancedMode = {
@@ -1 +1 @@
1
- {"version":3,"file":"Ellipsis.js","names":["_core","require","_baseComponents","_assignProps3","_findComponent","_interopRequireWildcard","_getOriginChildren","_interopRequireDefault","_pick","_reactToText","_ref8","_useEnhancedEffect","_tooltip","_react","_useResizeObserver","_utils","style","sstyled","insert","defaultTooltipProps","forcedAdvancedMode","noAdvancedMode","RootEllipsis","Component","constructor","args","_defineProperty2","default","visible","React","createRef","setState","showTooltip","maxLine","Children","asProps","text","reactToText","getOriginChildren","isTextOverflowing","textRef","current","getContentProps","ref","getPopperProps","includeTooltipProps","tooltipProps","pick","children","render","_ref3","SEllipsis","Root","SContainer","Tooltip","styles","tooltip","trim","containerRect","containerRef","_children","other","state","advancedContent","findComponent","Ellipsis","Content","displayName","advanceMode","isAdvanceMode","Popper","onVisibleChange","callAllEventHandlers","handlerVisibleChange","_ref2","createElement","EllipsisMiddle","cn","undefined","Box","__excludeProps","EllipsisMiddleContext","createContext","props","_ref5","tag","resizeElement","useRef","symbolWidth","setSymbolWidth","useState","blockWidth","useResizeObserver","width","useEnhancedEffect","node","styleElement","window","getComputedStyle","dateSpan","document","setFontSettings","textContent","body","appendChild","rect","getBoundingClientRect","removeChild","STail","SBeginning","SContainerMiddle","SAdvancedModeContainerMiddle","displayedSymbols","useMemo","Math","round","interaction","length","contextValue","begining","substring","tail","_ref4","Provider","value","forkRef","_ref","arguments[0]","_ref7","Trigger","ellipsisMiddleContext","useContext","_ref6","assignProps","createComponent","_default","exports"],"sources":["../../src/Ellipsis.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@semcore/base-components';\nimport { createComponent, Component, type Intergalactic, Root, sstyled } from '@semcore/core';\nimport { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';\nimport findComponent, { isAdvanceMode } from '@semcore/core/lib/utils/findComponent';\nimport getOriginChildren from '@semcore/core/lib/utils/getOriginChildren';\nimport pick from '@semcore/core/lib/utils/pick';\nimport reactToText from '@semcore/core/lib/utils/reactToText';\nimport { forkRef } from '@semcore/core/lib/utils/ref';\nimport useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';\nimport Tooltip, { type TooltipProps } from '@semcore/tooltip';\nimport React, { type RefObject } from 'react';\n\nimport style from './style/ellipsis.shadow.css';\nimport { useResizeObserver } from './useResizeObserver';\nimport { isTextOverflowing, setFontSettings } from './utils';\n\ntype AsProps = {\n maxLine?: number;\n trim?: 'end' | 'middle';\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n includeTooltipProps?: string[];\n __excludeProps?: string[];\n};\n\ntype AsPropsMiddle = {\n text: string;\n textRef: RefObject<HTMLDivElement>;\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n tooltipProps: TooltipProps;\n children?: React.ReactNode;\n advanceMode?: boolean;\n tag?: React.ElementType;\n};\n\ntype EllipsisProps = BoxProps &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLDivElement>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ntype DefaultProps = {\n trim: 'end';\n tooltip: true;\n includeTooltipProps: typeof defaultTooltipProps;\n __excludeProps: AsProps['__excludeProps'];\n};\n\ntype EllipsisComponent = Intergalactic.Component<'div', EllipsisProps> & {\n Content: typeof Box;\n Popper: typeof Tooltip.Popper;\n};\n\nconst defaultTooltipProps = [\n 'title',\n 'theme',\n 'strategy',\n 'modifiers',\n 'placement',\n 'interaction',\n 'timeout',\n 'visible',\n 'defaultVisible',\n 'onVisibleChange',\n 'offset',\n 'preventOverflow',\n 'arrow',\n 'flip',\n 'computeStyles',\n 'eventListeners',\n 'onFirstUpdate',\n 'cursorAnchoring',\n];\n\nconst forcedAdvancedMode = { forcedAdvancedMode: true } as any;\nconst noAdvancedMode = {} as any;\n\nclass RootEllipsis extends Component<\n AsProps,\n [],\n {},\n {},\n {},\n DefaultProps\n> {\n static displayName = 'Ellipsis';\n static style = style;\n static defaultProps = {\n trim: 'end' as const,\n tooltip: true as const,\n includeTooltipProps: defaultTooltipProps,\n __excludeProps: ['title'],\n };\n\n state = {\n visible: false,\n };\n\n textRef = React.createRef<HTMLDivElement>();\n\n showTooltip() {\n const { maxLine = 1, Children } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n return isTextOverflowing(this.textRef.current, maxLine > 1, text);\n }\n\n handlerVisibleChange = (visible: boolean) => {\n this.setState({ visible: visible && this.showTooltip() });\n };\n\n getContentProps() {\n return {\n ref: this.textRef,\n maxLine: this.asProps.maxLine,\n };\n }\n\n getPopperProps() {\n const { Children, includeTooltipProps } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n return { children: text, ...tooltipProps };\n }\n\n render() {\n const SEllipsis = this.Root;\n const SContainer = Tooltip;\n const {\n styles,\n Children,\n maxLine,\n tooltip,\n trim,\n containerRect,\n containerRef,\n includeTooltipProps,\n children: _children,\n ...other\n } = this.asProps;\n const { visible } = this.state;\n const advancedContent = findComponent(Children, [(Ellipsis as any).Content.displayName]);\n const text = reactToText(advancedContent || getOriginChildren(Children));\n const advanceMode = isAdvanceMode(Children, [\n (Ellipsis as any).Content.displayName,\n (Ellipsis as any).Popper.displayName,\n ]);\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n\n tooltipProps.visible = tooltipProps.visible ?? visible;\n tooltipProps.onVisibleChange = tooltipProps.onVisibleChange\n ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange)\n : this.handlerVisibleChange;\n\n if (trim === 'middle') {\n return sstyled(styles)(\n <EllipsisMiddle\n text={text}\n styles={styles}\n tooltip={tooltip}\n containerRect={containerRect}\n containerRef={containerRef}\n textRef={this.textRef}\n tooltipProps={tooltipProps}\n advanceMode={advanceMode}\n {...other}\n >\n <Children />\n </EllipsisMiddle>,\n );\n }\n\n return sstyled(styles)(\n <SContainer\n interaction={tooltip ? 'hover' : 'none'}\n title={!advanceMode ? text : undefined}\n {...tooltipProps}\n {...(advanceMode ? forcedAdvancedMode : noAdvancedMode)}\n >\n {advanceMode\n ? (\n <Children />\n )\n : (\n <SEllipsis render={Box} ref={this.textRef} maxLine={maxLine} {...other}>\n <Children />\n </SEllipsis>\n )}\n </SContainer>,\n );\n }\n}\n\nconst EllipsisMiddleContext = React.createContext<null | {\n begining: string;\n tail: string;\n ref: React.RefObject<HTMLElement>;\n}>(null);\n\nfunction EllipsisMiddle(props: AsPropsMiddle) {\n const {\n styles,\n text,\n tooltip,\n containerRect,\n containerRef,\n textRef,\n tooltipProps,\n children,\n advanceMode,\n tag,\n } = props;\n\n const resizeElement = React.useRef<HTMLDivElement>(null);\n const [symbolWidth, setSymbolWidth] = React.useState(0);\n const blockWidth = useResizeObserver(resizeElement, containerRect).width;\n\n useEnhancedEffect(() => {\n const node = containerRef?.current || resizeElement?.current;\n if (!node) return;\n\n const styleElement = window.getComputedStyle(node);\n const dateSpan = document.createElement('temporary-block');\n\n setFontSettings(dateSpan, styleElement);\n dateSpan.textContent = 'a';\n document.body.appendChild(dateSpan);\n const rect = dateSpan.getBoundingClientRect();\n\n setSymbolWidth(rect.width);\n document.body.removeChild(dateSpan);\n }, []);\n\n const STail = 'span';\n const SBeginning = 'span';\n const SContainerMiddle = Tooltip;\n const SAdvancedModeContainerMiddle = Tooltip;\n const displayedSymbols = React.useMemo(\n () => {\n const displayedSymbols = Math.round(blockWidth / symbolWidth);\n\n return displayedSymbols % 2 === 0 ? displayedSymbols : displayedSymbols - 1;\n },\n [blockWidth, symbolWidth],\n );\n\n const interaction = text.length > displayedSymbols ? 'hover' : 'none';\n const ref = containerRef ?? resizeElement;\n const contextValue = React.useMemo(\n () => ({\n begining: text.substring(0, text.length - displayedSymbols / 2 - 1),\n tail: text.substring(text.length - displayedSymbols / 2 - 1),\n ref,\n }),\n [text, displayedSymbols],\n );\n\n if (advanceMode) {\n return sstyled(styles)(\n <SAdvancedModeContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n {...tooltipProps}\n {...forcedAdvancedMode}\n >\n <EllipsisMiddleContext.Provider value={contextValue}>\n {children}\n </EllipsisMiddleContext.Provider>\n </SAdvancedModeContainerMiddle>,\n );\n }\n return sstyled(styles)(\n <SContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n title={text}\n ref={forkRef(ref, textRef)}\n tag={tag}\n {...tooltipProps}\n >\n <SBeginning>{contextValue.begining}</SBeginning>\n <STail>{contextValue.tail}</STail>\n </SContainerMiddle>,\n );\n}\n\ntype EllipsisContentAsProps = {\n styles: any;\n Children: React.FC;\n};\n\nfunction Content({ styles, Children }: EllipsisContentAsProps) {\n const SEllipsis = Root;\n const ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);\n const STail = 'span';\n const SBeginning = 'span';\n\n if (ellipsisMiddleContext) {\n const { begining, tail, ref } = ellipsisMiddleContext;\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger} middle-mod ref={ref}>\n <SBeginning>{begining}</SBeginning>\n <STail>{tail}</STail>\n </SEllipsis>,\n ) as any;\n }\n\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger}>\n <Children />\n </SEllipsis>,\n ) as any;\n}\n\n/**\n * Ellipsis\n *\n * {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-api/|API} | {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-code/|Examples}\n */\nconst Ellipsis = createComponent<\n EllipsisComponent,\n typeof RootEllipsis\n>(RootEllipsis, {\n Content,\n Popper: Tooltip.Popper,\n});\n\nexport default Ellipsis;\n"],"mappings":";;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,KAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,YAAA,GAAAF,sBAAA,CAAAN,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,kBAAA,GAAAJ,sBAAA,CAAAN,OAAA;AACA,IAAAW,QAAA,GAAAL,sBAAA,CAAAN,OAAA;AACA,IAAAY,MAAA,GAAAN,sBAAA,CAAAN,OAAA;AAGA,IAAAa,kBAAA,GAAAb,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AAA6D;AAAA,MAAAe,KAAA,8BAAAhB,KAAA,CAAAiB,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAuE7D,MAAMC,mBAAmB,GAAG,CAC1B,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,OAAO,EACP,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,CAClB;AAED,MAAMC,kBAAkB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aAAO,EAACsC,MAAM,CAAC,eACpB1C,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACxB,SAAS,EAAAiF,KAAA,CAAAvD,EAAA;MAAA,OAAA7E,KAAA,CAAAqI,WAAA;QAAA;QAAA,OAA0C1F;MAAG,GAAAmF,IAAA;IAAA,iBACrDjH,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACkC,UAAU,EAAAuB,KAAA,CAAAvD,EAAA,oBAAE0C,QAAqB,CAAC,eACnC1G,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACiC,KAAK,EAAAwB,KAAA,CAAAvD,EAAA,eAAE4C,IAAY,CACX,CAAC;EAEhB;EAEA,OAAAO,KAAA,GAAO,IAAA/G,aAAO,EAACsC,MAAM,CAAC,eACpB1C,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACxB,SAAS,EAAA6E,KAAA,CAAAnD,EAAA;IAAA,OAAA7E,KAAA,CAAAqI,WAAA,MAAAP,IAAA;EAAA,iBACRjH,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACzC,QAAQ,EAAA8F,KAAA,CAAAnD,EAAA,gBAAE,CACF,CAAC;AAEhB;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMZ,QAAQ,GAAG,IAAAqE,qBAAe,EAG9BhH,YAAY,EAAE;EACd4C,OAAO;EACPI,MAAM,EAAEhB,gBAAO,CAACgB;AAClB,CAAC,CAAC;AAAC,IAAAiE,QAAA,GAAAC,OAAA,CAAA7G,OAAA,GAEYsC,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Ellipsis.js","names":["_core","require","_baseComponents","_assignProps3","_findComponent","_interopRequireWildcard","_getOriginChildren","_interopRequireDefault","_pick","_reactToText","_ref8","_useEnhancedEffect","_tooltip","_react","_useResizeObserver","_utils","style","sstyled","insert","defaultTooltipProps","forcedAdvancedMode","noAdvancedMode","RootEllipsis","Component","constructor","args","_defineProperty2","default","visible","React","createRef","setState","showTooltip","maxLine","Children","asProps","text","reactToText","getOriginChildren","isTextOverflowing","textRef","current","getContentProps","ref","getPopperProps","includeTooltipProps","tooltipProps","pick","children","render","_ref3","SEllipsis","Root","SContainer","Tooltip","styles","tooltip","trim","containerRect","containerRef","_children","other","state","advancedContent","findComponent","Ellipsis","Content","displayName","advanceMode","isAdvanceMode","Popper","onVisibleChange","callAllEventHandlers","handlerVisibleChange","_ref2","createElement","EllipsisMiddle","cn","undefined","Box","__excludeProps","EllipsisMiddleContext","createContext","props","_ref5","tag","resizeElement","useRef","symbolWidth","setSymbolWidth","useState","blockWidth","useResizeObserver","width","useEnhancedEffect","node","styleElement","window","getComputedStyle","dateSpan","document","setFontSettings","textContent","body","appendChild","rect","getBoundingClientRect","removeChild","STail","SBeginning","SContainerMiddle","SAdvancedModeContainerMiddle","displayedSymbols","useMemo","Math","round","interaction","length","contextValue","begining","substring","tail","_ref4","Provider","value","forkRef","_ref","arguments[0]","_ref7","Trigger","ellipsisMiddleContext","useContext","_ref6","assignProps","createComponent","_default","exports"],"sources":["../../src/Ellipsis.tsx"],"sourcesContent":["import type { NSBox } from '@semcore/base-components';\nimport { Box } from '@semcore/base-components';\nimport { createComponent, Component, type Intergalactic, Root, sstyled } from '@semcore/core';\nimport { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';\nimport findComponent, { isAdvanceMode } from '@semcore/core/lib/utils/findComponent';\nimport getOriginChildren from '@semcore/core/lib/utils/getOriginChildren';\nimport pick from '@semcore/core/lib/utils/pick';\nimport reactToText from '@semcore/core/lib/utils/reactToText';\nimport { forkRef } from '@semcore/core/lib/utils/ref';\nimport useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';\nimport Tooltip, { type TooltipProps } from '@semcore/tooltip';\nimport React, { type RefObject } from 'react';\n\nimport style from './style/ellipsis.shadow.css';\nimport { useResizeObserver } from './useResizeObserver';\nimport { isTextOverflowing, setFontSettings } from './utils';\n\ntype AsProps = {\n maxLine?: number;\n trim?: 'end' | 'middle';\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n includeTooltipProps?: string[];\n __excludeProps?: string[];\n};\n\ntype AsPropsMiddle = {\n text: string;\n textRef: RefObject<HTMLDivElement>;\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n tooltipProps: TooltipProps;\n children?: React.ReactNode;\n advanceMode?: boolean;\n tag?: React.ElementType;\n};\n\ntype EllipsisProps = NSBox.Props &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLDivElement>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ntype DefaultProps = {\n trim: 'end';\n tooltip: true;\n includeTooltipProps: typeof defaultTooltipProps;\n __excludeProps: AsProps['__excludeProps'];\n};\n\ntype EllipsisComponent = Intergalactic.Component<'div', EllipsisProps> & {\n Content: NSBox.Component;\n Popper: typeof Tooltip.Popper;\n};\n\nconst defaultTooltipProps = [\n 'title',\n 'theme',\n 'strategy',\n 'modifiers',\n 'placement',\n 'interaction',\n 'timeout',\n 'visible',\n 'defaultVisible',\n 'onVisibleChange',\n 'offset',\n 'preventOverflow',\n 'arrow',\n 'flip',\n 'computeStyles',\n 'eventListeners',\n 'onFirstUpdate',\n 'cursorAnchoring',\n];\n\nconst forcedAdvancedMode = { forcedAdvancedMode: true } as any;\nconst noAdvancedMode = {} as any;\n\nclass RootEllipsis extends Component<\n AsProps,\n [],\n {},\n {},\n {},\n DefaultProps\n> {\n static displayName = 'Ellipsis';\n static style = style;\n static defaultProps = {\n trim: 'end' as const,\n tooltip: true as const,\n includeTooltipProps: defaultTooltipProps,\n __excludeProps: ['title'],\n };\n\n state = {\n visible: false,\n };\n\n textRef = React.createRef<HTMLDivElement>();\n\n showTooltip() {\n const { maxLine = 1, Children } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n return isTextOverflowing(this.textRef.current, maxLine > 1, text);\n }\n\n handlerVisibleChange = (visible: boolean) => {\n this.setState({ visible: visible && this.showTooltip() });\n };\n\n getContentProps() {\n return {\n ref: this.textRef,\n maxLine: this.asProps.maxLine,\n };\n }\n\n getPopperProps() {\n const { Children, includeTooltipProps } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n return { children: text, ...tooltipProps };\n }\n\n render() {\n const SEllipsis = this.Root;\n const SContainer = Tooltip;\n const {\n styles,\n Children,\n maxLine,\n tooltip,\n trim,\n containerRect,\n containerRef,\n includeTooltipProps,\n children: _children,\n ...other\n } = this.asProps;\n const { visible } = this.state;\n const advancedContent = findComponent(Children, [(Ellipsis as any).Content.displayName]);\n const text = reactToText(advancedContent || getOriginChildren(Children));\n const advanceMode = isAdvanceMode(Children, [\n (Ellipsis as any).Content.displayName,\n (Ellipsis as any).Popper.displayName,\n ]);\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n\n tooltipProps.visible = tooltipProps.visible ?? visible;\n tooltipProps.onVisibleChange = tooltipProps.onVisibleChange\n ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange)\n : this.handlerVisibleChange;\n\n if (trim === 'middle') {\n return sstyled(styles)(\n <EllipsisMiddle\n text={text}\n styles={styles}\n tooltip={tooltip}\n containerRect={containerRect}\n containerRef={containerRef}\n textRef={this.textRef}\n tooltipProps={tooltipProps}\n advanceMode={advanceMode}\n {...other}\n >\n <Children />\n </EllipsisMiddle>,\n );\n }\n\n return sstyled(styles)(\n <SContainer\n interaction={tooltip ? 'hover' : 'none'}\n title={!advanceMode ? text : undefined}\n {...tooltipProps}\n {...(advanceMode ? forcedAdvancedMode : noAdvancedMode)}\n >\n {advanceMode\n ? (\n <Children />\n )\n : (\n <SEllipsis render={Box} ref={this.textRef} maxLine={maxLine} {...other}>\n <Children />\n </SEllipsis>\n )}\n </SContainer>,\n );\n }\n}\n\nconst EllipsisMiddleContext = React.createContext<null | {\n begining: string;\n tail: string;\n ref: React.RefObject<HTMLElement>;\n}>(null);\n\nfunction EllipsisMiddle(props: AsPropsMiddle) {\n const {\n styles,\n text,\n tooltip,\n containerRect,\n containerRef,\n textRef,\n tooltipProps,\n children,\n advanceMode,\n tag,\n } = props;\n\n const resizeElement = React.useRef<HTMLDivElement>(null);\n const [symbolWidth, setSymbolWidth] = React.useState(0);\n const blockWidth = useResizeObserver(resizeElement, containerRect).width;\n\n useEnhancedEffect(() => {\n const node = containerRef?.current || resizeElement?.current;\n if (!node) return;\n\n const styleElement = window.getComputedStyle(node);\n const dateSpan = document.createElement('temporary-block');\n\n setFontSettings(dateSpan, styleElement);\n dateSpan.textContent = 'a';\n document.body.appendChild(dateSpan);\n const rect = dateSpan.getBoundingClientRect();\n\n setSymbolWidth(rect.width);\n document.body.removeChild(dateSpan);\n }, []);\n\n const STail = 'span';\n const SBeginning = 'span';\n const SContainerMiddle = Tooltip;\n const SAdvancedModeContainerMiddle = Tooltip;\n const displayedSymbols = React.useMemo(\n () => {\n const displayedSymbols = Math.round(blockWidth / symbolWidth);\n\n return displayedSymbols % 2 === 0 ? displayedSymbols : displayedSymbols - 1;\n },\n [blockWidth, symbolWidth],\n );\n\n const interaction = text.length > displayedSymbols ? 'hover' : 'none';\n const ref = containerRef ?? resizeElement;\n const contextValue = React.useMemo(\n () => ({\n begining: text.substring(0, text.length - displayedSymbols / 2 - 1),\n tail: text.substring(text.length - displayedSymbols / 2 - 1),\n ref,\n }),\n [text, displayedSymbols],\n );\n\n if (advanceMode) {\n return sstyled(styles)(\n <SAdvancedModeContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n {...tooltipProps}\n {...forcedAdvancedMode}\n >\n <EllipsisMiddleContext.Provider value={contextValue}>\n {children}\n </EllipsisMiddleContext.Provider>\n </SAdvancedModeContainerMiddle>,\n );\n }\n return sstyled(styles)(\n <SContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n title={text}\n ref={forkRef(ref, textRef)}\n tag={tag}\n {...tooltipProps}\n >\n <SBeginning>{contextValue.begining}</SBeginning>\n <STail>{contextValue.tail}</STail>\n </SContainerMiddle>,\n );\n}\n\ntype EllipsisContentAsProps = {\n styles: any;\n Children: React.FC;\n};\n\nfunction Content({ styles, Children }: EllipsisContentAsProps) {\n const SEllipsis = Root;\n const ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);\n const STail = 'span';\n const SBeginning = 'span';\n\n if (ellipsisMiddleContext) {\n const { begining, tail, ref } = ellipsisMiddleContext;\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger} middle-mod ref={ref}>\n <SBeginning>{begining}</SBeginning>\n <STail>{tail}</STail>\n </SEllipsis>,\n ) as any;\n }\n\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger}>\n <Children />\n </SEllipsis>,\n ) as any;\n}\n\n/**\n * Ellipsis\n *\n * {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-api/|API} | {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-code/|Examples}\n */\nconst Ellipsis = createComponent<\n EllipsisComponent,\n typeof RootEllipsis\n>(RootEllipsis, {\n Content,\n Popper: Tooltip.Popper,\n});\n\nexport default Ellipsis;\n"],"mappings":";;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,c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EAEhB;EAEA,OAAAO,KAAA,GAAO,IAAA/G,aAAO,EAACsC,MAAM,CAAC,eACpB1C,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACxB,SAAS,EAAA6E,KAAA,CAAAnD,EAAA;IAAA,OAAA7E,KAAA,CAAAqI,WAAA,MAAAP,IAAA;EAAA,iBACRjH,MAAA,CAAAc,OAAA,CAAAgD,aAAA,CAACzC,QAAQ,EAAA8F,KAAA,CAAAnD,EAAA,gBAAE,CACF,CAAC;AAEhB;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMZ,QAAQ,GAAG,IAAAqE,qBAAe,EAG9BhH,YAAY,EAAE;EACd4C,OAAO;EACPI,MAAM,EAAEhB,gBAAO,CAACgB;AAClB,CAAC,CAAC;AAAC,IAAAiE,QAAA,GAAAC,OAAA,CAAA7G,OAAA,GAEYsC,QAAQ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { Box, BoxProps } from '@semcore/base-components';\nimport type { UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { TooltipProps } from '@semcore/tooltip';\nimport type Tooltip from '@semcore/tooltip';\nimport type { RefObject } from 'react';\n\nexport type EllipsisProps = BoxProps &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis.\n * Applies only for `trim = end`\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLElement | null>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ndeclare const useResizeObserver: (\n ref: RefObject<HTMLElement>,\n hookOverride?: { width: number },\n) => { width: number };\n/**\n * @deprecated. Use Text with ellipsis property for @semcore/typography.\n */\ndeclare const Ellipsis: Intergalactic.Component<'div', EllipsisProps> & {\n Content: typeof Box;\n Popper: typeof Tooltip.Popper;\n};\n\nexport default Ellipsis;\n\nexport { useResizeObserver };\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { NSBox } from '@semcore/base-components';\nimport type { UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { TooltipProps } from '@semcore/tooltip';\nimport type Tooltip from '@semcore/tooltip';\nimport type { RefObject } from 'react';\n\nexport type EllipsisProps = NSBox.Props &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis.\n * Applies only for `trim = end`\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLElement | null>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ndeclare const useResizeObserver: (\n ref: RefObject<HTMLElement>,\n hookOverride?: { width: number },\n) => { width: number };\n/**\n * @deprecated. Use Text with ellipsis property for @semcore/typography.\n */\ndeclare const Ellipsis: Intergalactic.Component<'div', EllipsisProps> & {\n Content: NSBox.Component;\n Popper: typeof Tooltip.Popper;\n};\n\nexport default Ellipsis;\n\nexport { useResizeObserver };\n"],"mappings":"","ignoreList":[]}
@@ -14,18 +14,18 @@ import useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';
14
14
  import Tooltip from '@semcore/tooltip';
15
15
  import React from 'react';
16
16
  /*!__reshadow-styles__:"./style/ellipsis.shadow.css"*/
17
- const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SBeginning_1q1qt_gg_,.___SEllipsis_1q1qt_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SContainerMiddle_1q1qt_gg_,.___SContainer_1q1qt_gg_,.___SNoTooltipContainer_1q1qt_gg_{display:flex;overflow:hidden}.___SEllipsis_1q1qt_gg_.__maxLine_1q1qt_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_1q1qt);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SEllipsis_1q1qt_gg_.__middle-mod_1q1qt_gg_{display:flex;overflow:hidden}.___SContainerMiddle_1q1qt_gg_>:has(.___SBeginning_1q1qt_gg_),.___SContainerMiddle_1q1qt_gg_>:has(.___STail_1q1qt_gg_){display:flex;width:100%}.___STail_1q1qt_gg_{white-space:pre}", /*__inner_css_end__*/"1q1qt_gg_"),
17
+ const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SBeginning_o4oo8_gg_,.___SEllipsis_o4oo8_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SContainerMiddle_o4oo8_gg_,.___SContainer_o4oo8_gg_,.___SNoTooltipContainer_o4oo8_gg_{display:flex;overflow:hidden}.___SEllipsis_o4oo8_gg_.__maxLine_o4oo8_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_o4oo8);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SEllipsis_o4oo8_gg_.__middle-mod_o4oo8_gg_{display:flex;overflow:hidden}.___SContainerMiddle_o4oo8_gg_>:has(.___SBeginning_o4oo8_gg_),.___SContainerMiddle_o4oo8_gg_>:has(.___STail_o4oo8_gg_){display:flex;width:100%}.___STail_o4oo8_gg_{white-space:pre}", /*__inner_css_end__*/"o4oo8_gg_"),
18
18
  /*__reshadow_css_end__*/
19
19
  {
20
- "__SBeginning": "___SBeginning_1q1qt_gg_",
21
- "__SEllipsis": "___SEllipsis_1q1qt_gg_",
22
- "__SContainer": "___SContainer_1q1qt_gg_",
23
- "__SNoTooltipContainer": "___SNoTooltipContainer_1q1qt_gg_",
24
- "__SContainerMiddle": "___SContainerMiddle_1q1qt_gg_",
25
- "_maxLine": "__maxLine_1q1qt_gg_",
26
- "--maxLine": "--maxLine_1q1qt",
27
- "_middle-mod": "__middle-mod_1q1qt_gg_",
28
- "__STail": "___STail_1q1qt_gg_"
20
+ "__SBeginning": "___SBeginning_o4oo8_gg_",
21
+ "__SEllipsis": "___SEllipsis_o4oo8_gg_",
22
+ "__SContainer": "___SContainer_o4oo8_gg_",
23
+ "__SNoTooltipContainer": "___SNoTooltipContainer_o4oo8_gg_",
24
+ "__SContainerMiddle": "___SContainerMiddle_o4oo8_gg_",
25
+ "_maxLine": "__maxLine_o4oo8_gg_",
26
+ "--maxLine": "--maxLine_o4oo8",
27
+ "_middle-mod": "__middle-mod_o4oo8_gg_",
28
+ "__STail": "___STail_o4oo8_gg_"
29
29
  });
30
30
  import { useResizeObserver } from './useResizeObserver';
31
31
  import { isTextOverflowing, setFontSettings } from './utils';
@@ -1 +1 @@
1
- {"version":3,"file":"Ellipsis.js","names":["Box","createComponent","Component","Root","sstyled","callAllEventHandlers","findComponent","isAdvanceMode","getOriginChildren","pick","reactToText","forkRef","useEnhancedEffect","Tooltip","React","style","_sstyled","insert","useResizeObserver","isTextOverflowing","setFontSettings","defaultTooltipProps","forcedAdvancedMode","noAdvancedMode","RootEllipsis","constructor","args","_defineProperty","visible","createRef","setState","showTooltip","maxLine","Children","asProps","text","textRef","current","getContentProps","ref","getPopperProps","includeTooltipProps","tooltipProps","children","render","_ref3","SEllipsis","SContainer","styles","tooltip","trim","containerRect","containerRef","_children","other","state","advancedContent","Ellipsis","Content","displayName","advanceMode","Popper","onVisibleChange","handlerVisibleChange","_ref2","createElement","EllipsisMiddle","cn","undefined","__excludeProps","EllipsisMiddleContext","createContext","props","_ref5","tag","resizeElement","useRef","symbolWidth","setSymbolWidth","useState","blockWidth","width","node","styleElement","window","getComputedStyle","dateSpan","document","textContent","body","appendChild","rect","getBoundingClientRect","removeChild","STail","SBeginning","SContainerMiddle","SAdvancedModeContainerMiddle","displayedSymbols","useMemo","Math","round","interaction","length","contextValue","begining","substring","tail","_ref4","Provider","value","_ref","arguments[0]","_ref7","Trigger","ellipsisMiddleContext","useContext","_ref6","_assignProps","_assignProps2"],"sources":["../../src/Ellipsis.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@semcore/base-components';\nimport { createComponent, Component, type Intergalactic, Root, sstyled } from '@semcore/core';\nimport { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';\nimport findComponent, { isAdvanceMode } from '@semcore/core/lib/utils/findComponent';\nimport getOriginChildren from '@semcore/core/lib/utils/getOriginChildren';\nimport pick from '@semcore/core/lib/utils/pick';\nimport reactToText from '@semcore/core/lib/utils/reactToText';\nimport { forkRef } from '@semcore/core/lib/utils/ref';\nimport useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';\nimport Tooltip, { type TooltipProps } from '@semcore/tooltip';\nimport React, { type RefObject } from 'react';\n\nimport style from './style/ellipsis.shadow.css';\nimport { useResizeObserver } from './useResizeObserver';\nimport { isTextOverflowing, setFontSettings } from './utils';\n\ntype AsProps = {\n maxLine?: number;\n trim?: 'end' | 'middle';\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n includeTooltipProps?: string[];\n __excludeProps?: string[];\n};\n\ntype AsPropsMiddle = {\n text: string;\n textRef: RefObject<HTMLDivElement>;\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n tooltipProps: TooltipProps;\n children?: React.ReactNode;\n advanceMode?: boolean;\n tag?: React.ElementType;\n};\n\ntype EllipsisProps = BoxProps &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLDivElement>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ntype DefaultProps = {\n trim: 'end';\n tooltip: true;\n includeTooltipProps: typeof defaultTooltipProps;\n __excludeProps: AsProps['__excludeProps'];\n};\n\ntype EllipsisComponent = Intergalactic.Component<'div', EllipsisProps> & {\n Content: typeof Box;\n Popper: typeof Tooltip.Popper;\n};\n\nconst defaultTooltipProps = [\n 'title',\n 'theme',\n 'strategy',\n 'modifiers',\n 'placement',\n 'interaction',\n 'timeout',\n 'visible',\n 'defaultVisible',\n 'onVisibleChange',\n 'offset',\n 'preventOverflow',\n 'arrow',\n 'flip',\n 'computeStyles',\n 'eventListeners',\n 'onFirstUpdate',\n 'cursorAnchoring',\n];\n\nconst forcedAdvancedMode = { forcedAdvancedMode: true } as any;\nconst noAdvancedMode = {} as any;\n\nclass RootEllipsis extends Component<\n AsProps,\n [],\n {},\n {},\n {},\n DefaultProps\n> {\n static displayName = 'Ellipsis';\n static style = style;\n static defaultProps = {\n trim: 'end' as const,\n tooltip: true as const,\n includeTooltipProps: defaultTooltipProps,\n __excludeProps: ['title'],\n };\n\n state = {\n visible: false,\n };\n\n textRef = React.createRef<HTMLDivElement>();\n\n showTooltip() {\n const { maxLine = 1, Children } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n return isTextOverflowing(this.textRef.current, maxLine > 1, text);\n }\n\n handlerVisibleChange = (visible: boolean) => {\n this.setState({ visible: visible && this.showTooltip() });\n };\n\n getContentProps() {\n return {\n ref: this.textRef,\n maxLine: this.asProps.maxLine,\n };\n }\n\n getPopperProps() {\n const { Children, includeTooltipProps } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n return { children: text, ...tooltipProps };\n }\n\n render() {\n const SEllipsis = this.Root;\n const SContainer = Tooltip;\n const {\n styles,\n Children,\n maxLine,\n tooltip,\n trim,\n containerRect,\n containerRef,\n includeTooltipProps,\n children: _children,\n ...other\n } = this.asProps;\n const { visible } = this.state;\n const advancedContent = findComponent(Children, [(Ellipsis as any).Content.displayName]);\n const text = reactToText(advancedContent || getOriginChildren(Children));\n const advanceMode = isAdvanceMode(Children, [\n (Ellipsis as any).Content.displayName,\n (Ellipsis as any).Popper.displayName,\n ]);\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n\n tooltipProps.visible = tooltipProps.visible ?? visible;\n tooltipProps.onVisibleChange = tooltipProps.onVisibleChange\n ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange)\n : this.handlerVisibleChange;\n\n if (trim === 'middle') {\n return sstyled(styles)(\n <EllipsisMiddle\n text={text}\n styles={styles}\n tooltip={tooltip}\n containerRect={containerRect}\n containerRef={containerRef}\n textRef={this.textRef}\n tooltipProps={tooltipProps}\n advanceMode={advanceMode}\n {...other}\n >\n <Children />\n </EllipsisMiddle>,\n );\n }\n\n return sstyled(styles)(\n <SContainer\n interaction={tooltip ? 'hover' : 'none'}\n title={!advanceMode ? text : undefined}\n {...tooltipProps}\n {...(advanceMode ? forcedAdvancedMode : noAdvancedMode)}\n >\n {advanceMode\n ? (\n <Children />\n )\n : (\n <SEllipsis render={Box} ref={this.textRef} maxLine={maxLine} {...other}>\n <Children />\n </SEllipsis>\n )}\n </SContainer>,\n );\n }\n}\n\nconst EllipsisMiddleContext = React.createContext<null | {\n begining: string;\n tail: string;\n ref: React.RefObject<HTMLElement>;\n}>(null);\n\nfunction EllipsisMiddle(props: AsPropsMiddle) {\n const {\n styles,\n text,\n tooltip,\n containerRect,\n containerRef,\n textRef,\n tooltipProps,\n children,\n advanceMode,\n tag,\n } = props;\n\n const resizeElement = React.useRef<HTMLDivElement>(null);\n const [symbolWidth, setSymbolWidth] = React.useState(0);\n const blockWidth = useResizeObserver(resizeElement, containerRect).width;\n\n useEnhancedEffect(() => {\n const node = containerRef?.current || resizeElement?.current;\n if (!node) return;\n\n const styleElement = window.getComputedStyle(node);\n const dateSpan = document.createElement('temporary-block');\n\n setFontSettings(dateSpan, styleElement);\n dateSpan.textContent = 'a';\n document.body.appendChild(dateSpan);\n const rect = dateSpan.getBoundingClientRect();\n\n setSymbolWidth(rect.width);\n document.body.removeChild(dateSpan);\n }, []);\n\n const STail = 'span';\n const SBeginning = 'span';\n const SContainerMiddle = Tooltip;\n const SAdvancedModeContainerMiddle = Tooltip;\n const displayedSymbols = React.useMemo(\n () => {\n const displayedSymbols = Math.round(blockWidth / symbolWidth);\n\n return displayedSymbols % 2 === 0 ? displayedSymbols : displayedSymbols - 1;\n },\n [blockWidth, symbolWidth],\n );\n\n const interaction = text.length > displayedSymbols ? 'hover' : 'none';\n const ref = containerRef ?? resizeElement;\n const contextValue = React.useMemo(\n () => ({\n begining: text.substring(0, text.length - displayedSymbols / 2 - 1),\n tail: text.substring(text.length - displayedSymbols / 2 - 1),\n ref,\n }),\n [text, displayedSymbols],\n );\n\n if (advanceMode) {\n return sstyled(styles)(\n <SAdvancedModeContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n {...tooltipProps}\n {...forcedAdvancedMode}\n >\n <EllipsisMiddleContext.Provider value={contextValue}>\n {children}\n </EllipsisMiddleContext.Provider>\n </SAdvancedModeContainerMiddle>,\n );\n }\n return sstyled(styles)(\n <SContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n title={text}\n ref={forkRef(ref, textRef)}\n tag={tag}\n {...tooltipProps}\n >\n <SBeginning>{contextValue.begining}</SBeginning>\n <STail>{contextValue.tail}</STail>\n </SContainerMiddle>,\n );\n}\n\ntype EllipsisContentAsProps = {\n styles: any;\n Children: React.FC;\n};\n\nfunction Content({ styles, Children }: EllipsisContentAsProps) {\n const SEllipsis = Root;\n const ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);\n const STail = 'span';\n const SBeginning = 'span';\n\n if (ellipsisMiddleContext) {\n const { begining, tail, ref } = ellipsisMiddleContext;\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger} middle-mod ref={ref}>\n <SBeginning>{begining}</SBeginning>\n <STail>{tail}</STail>\n </SEllipsis>,\n ) as any;\n }\n\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger}>\n <Children />\n </SEllipsis>,\n ) as any;\n}\n\n/**\n * Ellipsis\n *\n * {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-api/|API} | {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-code/|Examples}\n */\nconst Ellipsis = createComponent<\n EllipsisComponent,\n typeof RootEllipsis\n>(RootEllipsis, {\n Content,\n Popper: Tooltip.Popper,\n});\n\nexport default Ellipsis;\n"],"mappings":";;;;AAAA,SAASA,GAAG,QAAuB,0BAA0B;AAC7D,SAASC,eAAe,EAAEC,SAAS,EAAsBC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAC7F,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,OAAOC,aAAa,IAAIC,aAAa,QAAQ,uCAAuC;AACpF,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,IAAI,MAAM,8BAA8B;AAC/C,OAAOC,WAAW,MAAM,qCAAqC;AAC7D,SAASC,OAAO,QAAQ,6BAA6B;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G,MAAM;EACpB,MAAMC,UAAU,GAAG,MAAM;EAEzB,IAAIoB,qBAAqB,EAAE;IAAA,IAAAE,KAAA;IACzB,MAAM;MAAEZ,QAAQ;MAAEE,IAAI;MAAEpE;IAAI,CAAC,GAAG4E,qBAAqB;IACrD,OAAAE,KAAA,GAAOjH,OAAO,CAAC4C,MAAM,CAAC,eACpBlC,KAAA,CAAAmD,aAAA,CAACnB,SAAS,EAAAuE,KAAA,CAAAlD,EAAA;MAAA,GAAAmD,YAAA;QAAA;QAAA,OAA0C/E;MAAG,GAAAwE,IAAA;IAAA,iBACrDjG,KAAA,CAAAmD,aAAA,CAAC8B,UAAU,EAAAsB,KAAA,CAAAlD,EAAA,oBAAEsC,QAAqB,CAAC,eACnC3F,KAAA,CAAAmD,aAAA,CAAC6B,KAAK,EAAAuB,KAAA,CAAAlD,EAAA,eAAEwC,IAAY,CACX,CAAC;EAEhB;EAEA,OAAAM,KAAA,GAAO7G,OAAO,CAAC4C,MAAM,CAAC,eACpBlC,KAAA,CAAAmD,aAAA,CAACnB,SAAS,EAAAmE,KAAA,CAAA9C,EAAA;IAAA,GAAAoD,aAAA,KAAAR,IAAA;EAAA,iBACRjG,KAAA,CAAAmD,aAAA,CAAChC,QAAQ,EAAAgF,KAAA,CAAA9C,EAAA,gBAAE,CACF,CAAC;AAEhB;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMV,QAAQ,GAAGxD,eAAe,CAG9BuB,YAAY,EAAE;EACdkC,OAAO;EACPG,MAAM,EAAEhD,OAAO,CAACgD;AAClB,CAAC,CAAC;AAEF,eAAeJ,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Ellipsis.js","names":["Box","createComponent","Component","Root","sstyled","callAllEventHandlers","findComponent","isAdvanceMode","getOriginChildren","pick","reactToText","forkRef","useEnhancedEffect","Tooltip","React","style","_sstyled","insert","useResizeObserver","isTextOverflowing","setFontSettings","defaultTooltipProps","forcedAdvancedMode","noAdvancedMode","RootEllipsis","constructor","args","_defineProperty","visible","createRef","setState","showTooltip","maxLine","Children","asProps","text","textRef","current","getContentProps","ref","getPopperProps","includeTooltipProps","tooltipProps","children","render","_ref3","SEllipsis","SContainer","styles","tooltip","trim","containerRect","containerRef","_children","other","state","advancedContent","Ellipsis","Content","displayName","advanceMode","Popper","onVisibleChange","handlerVisibleChange","_ref2","createElement","EllipsisMiddle","cn","undefined","__excludeProps","EllipsisMiddleContext","createContext","props","_ref5","tag","resizeElement","useRef","symbolWidth","setSymbolWidth","useState","blockWidth","width","node","styleElement","window","getComputedStyle","dateSpan","document","textContent","body","appendChild","rect","getBoundingClientRect","removeChild","STail","SBeginning","SContainerMiddle","SAdvancedModeContainerMiddle","displayedSymbols","useMemo","Math","round","interaction","length","contextValue","begining","substring","tail","_ref4","Provider","value","_ref","arguments[0]","_ref7","Trigger","ellipsisMiddleContext","useContext","_ref6","_assignProps","_assignProps2"],"sources":["../../src/Ellipsis.tsx"],"sourcesContent":["import type { NSBox } from '@semcore/base-components';\nimport { Box } from '@semcore/base-components';\nimport { createComponent, Component, type Intergalactic, Root, sstyled } from '@semcore/core';\nimport { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';\nimport findComponent, { isAdvanceMode } from '@semcore/core/lib/utils/findComponent';\nimport getOriginChildren from '@semcore/core/lib/utils/getOriginChildren';\nimport pick from '@semcore/core/lib/utils/pick';\nimport reactToText from '@semcore/core/lib/utils/reactToText';\nimport { forkRef } from '@semcore/core/lib/utils/ref';\nimport useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';\nimport Tooltip, { type TooltipProps } from '@semcore/tooltip';\nimport React, { type RefObject } from 'react';\n\nimport style from './style/ellipsis.shadow.css';\nimport { useResizeObserver } from './useResizeObserver';\nimport { isTextOverflowing, setFontSettings } from './utils';\n\ntype AsProps = {\n maxLine?: number;\n trim?: 'end' | 'middle';\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n includeTooltipProps?: string[];\n __excludeProps?: string[];\n};\n\ntype AsPropsMiddle = {\n text: string;\n textRef: RefObject<HTMLDivElement>;\n tooltip?: boolean;\n styles?: React.CSSProperties;\n containerRect?: { width: number };\n\n containerRef?: RefObject<HTMLDivElement>;\n tooltipProps: TooltipProps;\n children?: React.ReactNode;\n advanceMode?: boolean;\n tag?: React.ElementType;\n};\n\ntype EllipsisProps = NSBox.Props &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLDivElement>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ntype DefaultProps = {\n trim: 'end';\n tooltip: true;\n includeTooltipProps: typeof defaultTooltipProps;\n __excludeProps: AsProps['__excludeProps'];\n};\n\ntype EllipsisComponent = Intergalactic.Component<'div', EllipsisProps> & {\n Content: NSBox.Component;\n Popper: typeof Tooltip.Popper;\n};\n\nconst defaultTooltipProps = [\n 'title',\n 'theme',\n 'strategy',\n 'modifiers',\n 'placement',\n 'interaction',\n 'timeout',\n 'visible',\n 'defaultVisible',\n 'onVisibleChange',\n 'offset',\n 'preventOverflow',\n 'arrow',\n 'flip',\n 'computeStyles',\n 'eventListeners',\n 'onFirstUpdate',\n 'cursorAnchoring',\n];\n\nconst forcedAdvancedMode = { forcedAdvancedMode: true } as any;\nconst noAdvancedMode = {} as any;\n\nclass RootEllipsis extends Component<\n AsProps,\n [],\n {},\n {},\n {},\n DefaultProps\n> {\n static displayName = 'Ellipsis';\n static style = style;\n static defaultProps = {\n trim: 'end' as const,\n tooltip: true as const,\n includeTooltipProps: defaultTooltipProps,\n __excludeProps: ['title'],\n };\n\n state = {\n visible: false,\n };\n\n textRef = React.createRef<HTMLDivElement>();\n\n showTooltip() {\n const { maxLine = 1, Children } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n return isTextOverflowing(this.textRef.current, maxLine > 1, text);\n }\n\n handlerVisibleChange = (visible: boolean) => {\n this.setState({ visible: visible && this.showTooltip() });\n };\n\n getContentProps() {\n return {\n ref: this.textRef,\n maxLine: this.asProps.maxLine,\n };\n }\n\n getPopperProps() {\n const { Children, includeTooltipProps } = this.asProps;\n const text = reactToText(getOriginChildren(Children));\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n return { children: text, ...tooltipProps };\n }\n\n render() {\n const SEllipsis = this.Root;\n const SContainer = Tooltip;\n const {\n styles,\n Children,\n maxLine,\n tooltip,\n trim,\n containerRect,\n containerRef,\n includeTooltipProps,\n children: _children,\n ...other\n } = this.asProps;\n const { visible } = this.state;\n const advancedContent = findComponent(Children, [(Ellipsis as any).Content.displayName]);\n const text = reactToText(advancedContent || getOriginChildren(Children));\n const advanceMode = isAdvanceMode(Children, [\n (Ellipsis as any).Content.displayName,\n (Ellipsis as any).Popper.displayName,\n ]);\n const tooltipProps = pick(this.asProps, includeTooltipProps as any) as TooltipProps;\n\n tooltipProps.visible = tooltipProps.visible ?? visible;\n tooltipProps.onVisibleChange = tooltipProps.onVisibleChange\n ? callAllEventHandlers(tooltipProps.onVisibleChange, this.handlerVisibleChange)\n : this.handlerVisibleChange;\n\n if (trim === 'middle') {\n return sstyled(styles)(\n <EllipsisMiddle\n text={text}\n styles={styles}\n tooltip={tooltip}\n containerRect={containerRect}\n containerRef={containerRef}\n textRef={this.textRef}\n tooltipProps={tooltipProps}\n advanceMode={advanceMode}\n {...other}\n >\n <Children />\n </EllipsisMiddle>,\n );\n }\n\n return sstyled(styles)(\n <SContainer\n interaction={tooltip ? 'hover' : 'none'}\n title={!advanceMode ? text : undefined}\n {...tooltipProps}\n {...(advanceMode ? forcedAdvancedMode : noAdvancedMode)}\n >\n {advanceMode\n ? (\n <Children />\n )\n : (\n <SEllipsis render={Box} ref={this.textRef} maxLine={maxLine} {...other}>\n <Children />\n </SEllipsis>\n )}\n </SContainer>,\n );\n }\n}\n\nconst EllipsisMiddleContext = React.createContext<null | {\n begining: string;\n tail: string;\n ref: React.RefObject<HTMLElement>;\n}>(null);\n\nfunction EllipsisMiddle(props: AsPropsMiddle) {\n const {\n styles,\n text,\n tooltip,\n containerRect,\n containerRef,\n textRef,\n tooltipProps,\n children,\n advanceMode,\n tag,\n } = props;\n\n const resizeElement = React.useRef<HTMLDivElement>(null);\n const [symbolWidth, setSymbolWidth] = React.useState(0);\n const blockWidth = useResizeObserver(resizeElement, containerRect).width;\n\n useEnhancedEffect(() => {\n const node = containerRef?.current || resizeElement?.current;\n if (!node) return;\n\n const styleElement = window.getComputedStyle(node);\n const dateSpan = document.createElement('temporary-block');\n\n setFontSettings(dateSpan, styleElement);\n dateSpan.textContent = 'a';\n document.body.appendChild(dateSpan);\n const rect = dateSpan.getBoundingClientRect();\n\n setSymbolWidth(rect.width);\n document.body.removeChild(dateSpan);\n }, []);\n\n const STail = 'span';\n const SBeginning = 'span';\n const SContainerMiddle = Tooltip;\n const SAdvancedModeContainerMiddle = Tooltip;\n const displayedSymbols = React.useMemo(\n () => {\n const displayedSymbols = Math.round(blockWidth / symbolWidth);\n\n return displayedSymbols % 2 === 0 ? displayedSymbols : displayedSymbols - 1;\n },\n [blockWidth, symbolWidth],\n );\n\n const interaction = text.length > displayedSymbols ? 'hover' : 'none';\n const ref = containerRef ?? resizeElement;\n const contextValue = React.useMemo(\n () => ({\n begining: text.substring(0, text.length - displayedSymbols / 2 - 1),\n tail: text.substring(text.length - displayedSymbols / 2 - 1),\n ref,\n }),\n [text, displayedSymbols],\n );\n\n if (advanceMode) {\n return sstyled(styles)(\n <SAdvancedModeContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n {...tooltipProps}\n {...forcedAdvancedMode}\n >\n <EllipsisMiddleContext.Provider value={contextValue}>\n {children}\n </EllipsisMiddleContext.Provider>\n </SAdvancedModeContainerMiddle>,\n );\n }\n return sstyled(styles)(\n <SContainerMiddle\n interaction={tooltip ? interaction : 'none'}\n title={text}\n ref={forkRef(ref, textRef)}\n tag={tag}\n {...tooltipProps}\n >\n <SBeginning>{contextValue.begining}</SBeginning>\n <STail>{contextValue.tail}</STail>\n </SContainerMiddle>,\n );\n}\n\ntype EllipsisContentAsProps = {\n styles: any;\n Children: React.FC;\n};\n\nfunction Content({ styles, Children }: EllipsisContentAsProps) {\n const SEllipsis = Root;\n const ellipsisMiddleContext = React.useContext(EllipsisMiddleContext);\n const STail = 'span';\n const SBeginning = 'span';\n\n if (ellipsisMiddleContext) {\n const { begining, tail, ref } = ellipsisMiddleContext;\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger} middle-mod ref={ref}>\n <SBeginning>{begining}</SBeginning>\n <STail>{tail}</STail>\n </SEllipsis>,\n ) as any;\n }\n\n return sstyled(styles)(\n <SEllipsis render={Tooltip.Trigger}>\n <Children />\n </SEllipsis>,\n ) as any;\n}\n\n/**\n * Ellipsis\n *\n * {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-api/|API} | {@link https://developer.semrush.com/intergalactic/components/ellipsis/ellipsis-code/|Examples}\n */\nconst Ellipsis = createComponent<\n EllipsisComponent,\n typeof RootEllipsis\n>(RootEllipsis, {\n Content,\n Popper: Tooltip.Popper,\n});\n\nexport default Ellipsis;\n"],"mappings":";;;;AACA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,eAAe,EAAEC,SAAS,EAAsBC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAC7F,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,OAAOC,aAAa,IAAIC,aAAa,QAAQ,uC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oxProps } from '@semcore/base-components';\nimport type { UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { TooltipProps } from '@semcore/tooltip';\nimport type Tooltip from '@semcore/tooltip';\nimport type { RefObject } from 'react';\n\nexport type EllipsisProps = BoxProps &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis.\n * Applies only for `trim = end`\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLElement | null>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ndeclare const useResizeObserver: (\n ref: RefObject<HTMLElement>,\n hookOverride?: { width: number },\n) => { width: number };\n/**\n * @deprecated. Use Text with ellipsis property for @semcore/typography.\n */\ndeclare const Ellipsis: Intergalactic.Component<'div', EllipsisProps> & {\n Content: typeof Box;\n Popper: typeof Tooltip.Popper;\n};\n\nexport default Ellipsis;\n\nexport { useResizeObserver };\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { NSBox } from '@semcore/base-components';\nimport type { UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { TooltipProps } from '@semcore/tooltip';\nimport type Tooltip from '@semcore/tooltip';\nimport type { RefObject } from 'react';\n\nexport type EllipsisProps = NSBox.Props &\n Partial<TooltipProps> & {\n /**\n * Rows count in multiline Ellipsis.\n * Applies only for `trim = end`\n * @default 1\n */\n maxLine?: number;\n /**\n * Trimming type\n * @default end\n */\n trim?: 'end' | 'middle';\n /**\n * Show tooltip\n * @default true\n */\n tooltip?: boolean;\n /**\n * Ref to the item that will be observed by ResizeObserver\n */\n containerRef?: RefObject<HTMLElement | null>;\n /**\n * Explicit sizes of container text should be trimmed in\n **/\n containerRect?: { width: number };\n /** List of props that will be passed to tooltip\n * @default ['title', 'theme', 'strategy', 'modifiers', 'placement', 'interaction', 'timeout', 'visible', 'defaultVisible', 'onVisibleChange', 'offset', 'preventOverflow', 'arrow', 'flip', 'computeStyles', 'eventListeners', 'onFirstUpdate']\n */\n includeTooltipProps?: string[];\n };\n\ndeclare const useResizeObserver: (\n ref: RefObject<HTMLElement>,\n hookOverride?: { width: number },\n) => { width: number };\n/**\n * @deprecated. Use Text with ellipsis property for @semcore/typography.\n */\ndeclare const Ellipsis: Intergalactic.Component<'div', EllipsisProps> & {\n Content: NSBox.Component;\n Popper: typeof Tooltip.Popper;\n};\n\nexport default Ellipsis;\n\nexport { useResizeObserver };\n"],"mappings":"","ignoreList":[]}
@@ -17,20 +17,20 @@ const style = (
17
17
  /*__reshadow_css_start__*/
18
18
  (sstyled.insert(
19
19
  /*__inner_css_start__*/
20
- ".___SBeginning_1q1qt_gg_,.___SEllipsis_1q1qt_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SContainerMiddle_1q1qt_gg_,.___SContainer_1q1qt_gg_,.___SNoTooltipContainer_1q1qt_gg_{display:flex;overflow:hidden}.___SEllipsis_1q1qt_gg_.__maxLine_1q1qt_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_1q1qt);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SEllipsis_1q1qt_gg_.__middle-mod_1q1qt_gg_{display:flex;overflow:hidden}.___SContainerMiddle_1q1qt_gg_>:has(.___SBeginning_1q1qt_gg_),.___SContainerMiddle_1q1qt_gg_>:has(.___STail_1q1qt_gg_){display:flex;width:100%}.___STail_1q1qt_gg_{white-space:pre}",
20
+ ".___SBeginning_o4oo8_gg_,.___SEllipsis_o4oo8_gg_{overflow:hidden;display:inline-block;text-overflow:ellipsis;white-space:pre}.___SContainerMiddle_o4oo8_gg_,.___SContainer_o4oo8_gg_,.___SNoTooltipContainer_o4oo8_gg_{display:flex;overflow:hidden}.___SEllipsis_o4oo8_gg_.__maxLine_o4oo8_gg_{display:-webkit-box;-webkit-line-clamp:var(--maxLine_o4oo8);-webkit-box-orient:vertical;overflow:hidden;white-space:normal;word-wrap:break-word}.___SEllipsis_o4oo8_gg_.__middle-mod_o4oo8_gg_{display:flex;overflow:hidden}.___SContainerMiddle_o4oo8_gg_>:has(.___SBeginning_o4oo8_gg_),.___SContainerMiddle_o4oo8_gg_>:has(.___STail_o4oo8_gg_){display:flex;width:100%}.___STail_o4oo8_gg_{white-space:pre}",
21
21
  /*__inner_css_end__*/
22
- "1q1qt_gg_"
22
+ "o4oo8_gg_"
23
23
  ), /*__reshadow_css_end__*/
24
24
  {
25
- "__SBeginning": "___SBeginning_1q1qt_gg_",
26
- "__SEllipsis": "___SEllipsis_1q1qt_gg_",
27
- "__SContainer": "___SContainer_1q1qt_gg_",
28
- "__SNoTooltipContainer": "___SNoTooltipContainer_1q1qt_gg_",
29
- "__SContainerMiddle": "___SContainerMiddle_1q1qt_gg_",
30
- "_maxLine": "__maxLine_1q1qt_gg_",
31
- "--maxLine": "--maxLine_1q1qt",
32
- "_middle-mod": "__middle-mod_1q1qt_gg_",
33
- "__STail": "___STail_1q1qt_gg_"
25
+ "__SBeginning": "___SBeginning_o4oo8_gg_",
26
+ "__SEllipsis": "___SEllipsis_o4oo8_gg_",
27
+ "__SContainer": "___SContainer_o4oo8_gg_",
28
+ "__SNoTooltipContainer": "___SNoTooltipContainer_o4oo8_gg_",
29
+ "__SContainerMiddle": "___SContainerMiddle_o4oo8_gg_",
30
+ "_maxLine": "__maxLine_o4oo8_gg_",
31
+ "--maxLine": "--maxLine_o4oo8",
32
+ "_middle-mod": "__middle-mod_o4oo8_gg_",
33
+ "__STail": "___STail_o4oo8_gg_"
34
34
  })
35
35
  );
36
36
  const defaultTooltipProps = ["title", "theme", "strategy", "modifiers", "placement", "interaction", "timeout", "visible", "defaultVisible", "onVisibleChange", "offset", "preventOverflow", "arrow", "flip", "computeStyles", "eventListeners", "onFirstUpdate", "cursorAnchoring"];
@@ -1,10 +1,10 @@
1
- import type { Box, BoxProps } from '@semcore/base-components';
1
+ import type { NSBox } from '@semcore/base-components';
2
2
  import type { UnknownProperties, Intergalactic } from '@semcore/core';
3
3
  import type { TooltipProps } from '@semcore/tooltip';
4
4
  import type Tooltip from '@semcore/tooltip';
5
5
  import type { RefObject } from 'react';
6
6
 
7
- export type EllipsisProps = BoxProps &
7
+ export type EllipsisProps = NSBox.Props &
8
8
  Partial<TooltipProps> & {
9
9
  /**
10
10
  * Rows count in multiline Ellipsis.
@@ -44,7 +44,7 @@ declare const useResizeObserver: (
44
44
  * @deprecated. Use Text with ellipsis property for @semcore/typography.
45
45
  */
46
46
  declare const Ellipsis: Intergalactic.Component<'div', EllipsisProps> & {
47
- Content: typeof Box;
47
+ Content: NSBox.Component;
48
48
  Popper: typeof Tooltip.Popper;
49
49
  };
50
50
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/ellipsis",
3
3
  "description": "Semrush Ellipsis Component",
4
- "version": "17.2.1",
4
+ "version": "17.2.2-prerelease.11",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,15 +14,15 @@
14
14
  "require": "./lib/cjs/index.js"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/tooltip": "^17.2.1"
17
+ "@semcore/tooltip": "^17.2.1-prerelease.11"
18
18
  },
19
19
  "peerDependencies": {
20
- "@semcore/base-components": "^17.2.1"
20
+ "@semcore/base-components": "^17.2.2-prerelease.11"
21
21
  },
22
22
  "devDependencies": {
23
- "@semcore/core": "17.2.1",
23
+ "@semcore/core": "17.3.1-prerelease.11",
24
24
  "@semcore/testing-utils": "1.0.0",
25
- "@semcore/base-components": "17.2.1"
25
+ "@semcore/base-components": "17.2.2-prerelease.11"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
4
- "compilerOptions": {
5
- "rootDir": "./src"
6
- },
7
- }