@telegraph/truncate 0.0.18 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @telegraph/truncate
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#688](https://github.com/knocklabs/telegraph/pull/688) [`8d55540`](https://github.com/knocklabs/telegraph/commit/8d5554005bea4695560efbee9ea4333ccddfc1bf) Thanks [@kylemcd](https://github.com/kylemcd)! - fix: invalid props on components would not throw type errors
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`8d55540`](https://github.com/knocklabs/telegraph/commit/8d5554005bea4695560efbee9ea4333ccddfc1bf)]:
12
+ - @telegraph/typography@0.2.0
13
+ - @telegraph/tooltip@0.1.0
14
+
3
15
  ## 0.0.18
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useTruncate/useTruncate.ts","../../src/TooltipIfTruncated/TooltipIfTruncated.tsx","../../src/TruncatedText/TruncatedText.tsx"],"sourcesContent":["import React from \"react\";\n\ntype UseTruncateParams = {\n tgphRef: React.RefObject<HTMLElement | null>;\n};\n\nconst useTruncate = (\n { tgphRef }: UseTruncateParams,\n deps: React.DependencyList = [],\n) => {\n const [truncated, setTruncated] = React.useState(false);\n\n React.useEffect(() => {\n if (!tgphRef.current) return setTruncated(false);\n\n const tgphRefElement = tgphRef.current;\n\n const checkTruncation = () => {\n setTruncated(tgphRefElement.scrollWidth > tgphRefElement.clientWidth);\n };\n\n // Initial check\n checkTruncation();\n\n // Add a resize observer to check for truncation when the element is resized\n const resizeObserver = new ResizeObserver(checkTruncation);\n resizeObserver.observe(tgphRefElement);\n\n // Clean up\n return () => {\n resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tgphRef, ...deps]);\n\n return { truncated };\n};\n\nexport { useTruncate };\n","import {\n type Optional,\n RefToTgphRef,\n type TgphComponentProps,\n} from \"@telegraph/helpers\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport React from \"react\";\n\nimport { useTruncate } from \"../useTruncate\";\n\ntype TooltipIfTruncatedProps = Optional<\n TgphComponentProps<typeof Tooltip>,\n \"label\"\n>;\n\nconst TooltipIfTruncated = ({\n label,\n children,\n ...props\n}: TooltipIfTruncatedProps) => {\n const truncateRef = React.useRef<HTMLButtonElement>(null);\n const { truncated } = useTruncate(\n { tgphRef: truncateRef as React.RefObject<HTMLElement> },\n [children],\n );\n\n // We extract the text so that we can properly wrap it in the Text component\n const textToDisplayInTooltip = React.useMemo(() => {\n if (typeof children === \"string\") return children;\n if (React.isValidElement(children)) {\n const childProps = children.props as Record<string, unknown>;\n return childProps.children;\n }\n return label;\n }, [children, label]);\n\n return (\n <Tooltip\n label={\n <Text as=\"span\" size=\"1\">\n {textToDisplayInTooltip as React.ReactNode}\n </Text>\n }\n enabled={truncated}\n triggerRef={truncateRef as React.RefObject<HTMLButtonElement>}\n {...props}\n >\n <RefToTgphRef>{children}</RefToTgphRef>\n </Tooltip>\n );\n};\n\nexport { TooltipIfTruncated };\n","import type { TgphComponentProps, TgphElement } from \"@telegraph/helpers\";\nimport { Text } from \"@telegraph/typography\";\n\nimport { TooltipIfTruncated } from \"../TooltipIfTruncated\";\n\ntype TruncatedTextProps<T extends TgphElement> = {\n tooltipProps?: Partial<TgphComponentProps<typeof TooltipIfTruncated>>;\n} & TgphComponentProps<typeof Text<T>>;\n\nconst TruncatedText = <T extends TgphElement>({\n tooltipProps,\n style,\n ...props\n}: TruncatedTextProps<T>) => {\n return (\n <TooltipIfTruncated {...tooltipProps}>\n <Text\n textOverflow=\"ellipsis\"\n overflow=\"hidden\"\n style={{\n display: \"block\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n </TooltipIfTruncated>\n );\n};\n\nexport { TruncatedText };\n"],"names":["useTruncate","tgphRef","deps","truncated","setTruncated","React","tgphRefElement","checkTruncation","resizeObserver","TooltipIfTruncated","label","children","props","truncateRef","textToDisplayInTooltip","jsx","Tooltip","Text","RefToTgphRef","TruncatedText","tooltipProps","style"],"mappings":"2OAMMA,EAAc,CAClB,CAAE,QAAAC,GACFC,EAA6B,CAAA,IAC1B,CACH,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAM,SAAS,EAAK,EAEtD,OAAAA,EAAM,UAAU,IAAM,CACpB,GAAI,CAACJ,EAAQ,QAAS,OAAOG,EAAa,EAAK,EAE/C,MAAME,EAAiBL,EAAQ,QAEzBM,EAAkB,IAAM,CAC5BH,EAAaE,EAAe,YAAcA,EAAe,WAAW,CACtE,EAGAC,EAAA,EAGA,MAAMC,EAAiB,IAAI,eAAeD,CAAe,EACzD,OAAAC,EAAe,QAAQF,CAAc,EAG9B,IAAM,CACXE,EAAe,WAAA,CACjB,CAEF,EAAG,CAACP,EAAS,GAAGC,CAAI,CAAC,EAEd,CAAE,UAAAC,CAAA,CACX,ECpBMM,EAAqB,CAAC,CAC1B,MAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAA+B,CAC7B,MAAMC,EAAcR,EAAM,OAA0B,IAAI,EAClD,CAAE,UAAAF,GAAcH,EACpB,CAAE,QAASa,CAAA,EACX,CAACF,CAAQ,CAAA,EAILG,EAAyBT,EAAM,QAAQ,IACvC,OAAOM,GAAa,SAAiBA,EACrCN,EAAM,eAAeM,CAAQ,EACZA,EAAS,MACV,SAEbD,EACN,CAACC,EAAUD,CAAK,CAAC,EAEpB,OACEK,EAAAA,IAACC,EAAAA,QAAA,CACC,MACED,EAAAA,IAACE,EAAAA,KAAA,CAAK,GAAG,OAAO,KAAK,IAClB,SAAAH,EACH,EAEF,QAASX,EACT,WAAYU,EACX,GAAGD,EAEJ,SAAAG,EAAAA,IAACG,gBAAc,SAAAP,CAAA,CAAS,CAAA,CAAA,CAG9B,EC1CMQ,EAAgB,CAAwB,CAC5C,aAAAC,EACA,MAAAC,EACA,GAAGT,CACL,IAEIG,EAAAA,IAACN,EAAA,CAAoB,GAAGW,EACtB,SAAAL,EAAAA,IAACE,EAAAA,KAAA,CACC,aAAa,WACb,SAAS,SACT,MAAO,CACL,QAAS,QACT,WAAY,SACZ,GAAGI,CAAA,EAEJ,GAAGT,CAAA,CAAA,EAER"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useTruncate/useTruncate.ts","../../src/TooltipIfTruncated/TooltipIfTruncated.tsx","../../src/TruncatedText/TruncatedText.tsx"],"sourcesContent":["import React from \"react\";\n\ntype UseTruncateParams = {\n tgphRef: React.RefObject<HTMLElement | null>;\n};\n\nconst useTruncate = (\n { tgphRef }: UseTruncateParams,\n deps: React.DependencyList = [],\n) => {\n const [truncated, setTruncated] = React.useState(false);\n\n React.useEffect(() => {\n if (!tgphRef.current) return setTruncated(false);\n\n const tgphRefElement = tgphRef.current;\n\n const checkTruncation = () => {\n setTruncated(tgphRefElement.scrollWidth > tgphRefElement.clientWidth);\n };\n\n // Initial check\n checkTruncation();\n\n // Add a resize observer to check for truncation when the element is resized\n const resizeObserver = new ResizeObserver(checkTruncation);\n resizeObserver.observe(tgphRefElement);\n\n // Clean up\n return () => {\n resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tgphRef, ...deps]);\n\n return { truncated };\n};\n\nexport { useTruncate };\n","import {\n type Optional,\n RefToTgphRef,\n type TgphComponentProps,\n} from \"@telegraph/helpers\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport React from \"react\";\n\nimport { useTruncate } from \"../useTruncate\";\n\nexport type TooltipIfTruncatedProps = Optional<\n TgphComponentProps<typeof Tooltip>,\n \"label\"\n>;\n\nconst TooltipIfTruncated = ({\n label,\n children,\n ...props\n}: TooltipIfTruncatedProps) => {\n const truncateRef = React.useRef<HTMLButtonElement>(null);\n const { truncated } = useTruncate(\n { tgphRef: truncateRef as React.RefObject<HTMLElement> },\n [children],\n );\n\n // We extract the text so that we can properly wrap it in the Text component\n const textToDisplayInTooltip = React.useMemo(() => {\n if (typeof children === \"string\") return children;\n if (React.isValidElement(children)) {\n const childProps = children.props as Record<string, unknown>;\n return childProps.children;\n }\n return label;\n }, [children, label]);\n\n return (\n <Tooltip\n label={\n <Text as=\"span\" size=\"1\">\n {textToDisplayInTooltip as React.ReactNode}\n </Text>\n }\n enabled={truncated}\n triggerRef={truncateRef as React.RefObject<HTMLButtonElement>}\n {...props}\n >\n <RefToTgphRef>{children}</RefToTgphRef>\n </Tooltip>\n );\n};\n\nexport { TooltipIfTruncated };\n","import type { TgphComponentProps, TgphElement } from \"@telegraph/helpers\";\nimport { Text } from \"@telegraph/typography\";\n\nimport { TooltipIfTruncated } from \"../TooltipIfTruncated\";\n\nexport type TruncatedTextProps<T extends TgphElement = \"span\"> = {\n tooltipProps?: Partial<TgphComponentProps<typeof TooltipIfTruncated>>;\n} & TgphComponentProps<typeof Text<T>>;\n\nconst TruncatedText = <T extends TgphElement = \"span\">({\n tooltipProps,\n style,\n ...props\n}: TruncatedTextProps<T>) => {\n return (\n <TooltipIfTruncated {...tooltipProps}>\n <Text\n textOverflow=\"ellipsis\"\n overflow=\"hidden\"\n style={{\n display: \"block\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n </TooltipIfTruncated>\n );\n};\n\nexport { TruncatedText };\n"],"names":["useTruncate","tgphRef","deps","truncated","setTruncated","React","tgphRefElement","checkTruncation","resizeObserver","TooltipIfTruncated","label","children","props","truncateRef","textToDisplayInTooltip","jsx","Tooltip","Text","RefToTgphRef","TruncatedText","tooltipProps","style"],"mappings":"2OAMMA,EAAc,CAClB,CAAE,QAAAC,GACFC,EAA6B,CAAA,IAC1B,CACH,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAM,SAAS,EAAK,EAEtD,OAAAA,EAAM,UAAU,IAAM,CACpB,GAAI,CAACJ,EAAQ,QAAS,OAAOG,EAAa,EAAK,EAE/C,MAAME,EAAiBL,EAAQ,QAEzBM,EAAkB,IAAM,CAC5BH,EAAaE,EAAe,YAAcA,EAAe,WAAW,CACtE,EAGAC,EAAA,EAGA,MAAMC,EAAiB,IAAI,eAAeD,CAAe,EACzD,OAAAC,EAAe,QAAQF,CAAc,EAG9B,IAAM,CACXE,EAAe,WAAA,CACjB,CAEF,EAAG,CAACP,EAAS,GAAGC,CAAI,CAAC,EAEd,CAAE,UAAAC,CAAA,CACX,ECpBMM,EAAqB,CAAC,CAC1B,MAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAA+B,CAC7B,MAAMC,EAAcR,EAAM,OAA0B,IAAI,EAClD,CAAE,UAAAF,GAAcH,EACpB,CAAE,QAASa,CAAA,EACX,CAACF,CAAQ,CAAA,EAILG,EAAyBT,EAAM,QAAQ,IACvC,OAAOM,GAAa,SAAiBA,EACrCN,EAAM,eAAeM,CAAQ,EACZA,EAAS,MACV,SAEbD,EACN,CAACC,EAAUD,CAAK,CAAC,EAEpB,OACEK,EAAAA,IAACC,EAAAA,QAAA,CACC,MACED,EAAAA,IAACE,EAAAA,KAAA,CAAK,GAAG,OAAO,KAAK,IAClB,SAAAH,EACH,EAEF,QAASX,EACT,WAAYU,EACX,GAAGD,EAEJ,SAAAG,EAAAA,IAACG,gBAAc,SAAAP,CAAA,CAAS,CAAA,CAAA,CAG9B,EC1CMQ,EAAgB,CAAiC,CACrD,aAAAC,EACA,MAAAC,EACA,GAAGT,CACL,IAEIG,EAAAA,IAACN,EAAA,CAAoB,GAAGW,EACtB,SAAAL,EAAAA,IAACE,EAAAA,KAAA,CACC,aAAa,WACb,SAAS,SACT,MAAO,CACL,QAAS,QACT,WAAY,SACZ,GAAGI,CAAA,EAEJ,GAAGT,CAAA,CAAA,EAER"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/useTruncate/useTruncate.ts","../../src/TooltipIfTruncated/TooltipIfTruncated.tsx","../../src/TruncatedText/TruncatedText.tsx"],"sourcesContent":["import React from \"react\";\n\ntype UseTruncateParams = {\n tgphRef: React.RefObject<HTMLElement | null>;\n};\n\nconst useTruncate = (\n { tgphRef }: UseTruncateParams,\n deps: React.DependencyList = [],\n) => {\n const [truncated, setTruncated] = React.useState(false);\n\n React.useEffect(() => {\n if (!tgphRef.current) return setTruncated(false);\n\n const tgphRefElement = tgphRef.current;\n\n const checkTruncation = () => {\n setTruncated(tgphRefElement.scrollWidth > tgphRefElement.clientWidth);\n };\n\n // Initial check\n checkTruncation();\n\n // Add a resize observer to check for truncation when the element is resized\n const resizeObserver = new ResizeObserver(checkTruncation);\n resizeObserver.observe(tgphRefElement);\n\n // Clean up\n return () => {\n resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tgphRef, ...deps]);\n\n return { truncated };\n};\n\nexport { useTruncate };\n","import {\n type Optional,\n RefToTgphRef,\n type TgphComponentProps,\n} from \"@telegraph/helpers\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport React from \"react\";\n\nimport { useTruncate } from \"../useTruncate\";\n\ntype TooltipIfTruncatedProps = Optional<\n TgphComponentProps<typeof Tooltip>,\n \"label\"\n>;\n\nconst TooltipIfTruncated = ({\n label,\n children,\n ...props\n}: TooltipIfTruncatedProps) => {\n const truncateRef = React.useRef<HTMLButtonElement>(null);\n const { truncated } = useTruncate(\n { tgphRef: truncateRef as React.RefObject<HTMLElement> },\n [children],\n );\n\n // We extract the text so that we can properly wrap it in the Text component\n const textToDisplayInTooltip = React.useMemo(() => {\n if (typeof children === \"string\") return children;\n if (React.isValidElement(children)) {\n const childProps = children.props as Record<string, unknown>;\n return childProps.children;\n }\n return label;\n }, [children, label]);\n\n return (\n <Tooltip\n label={\n <Text as=\"span\" size=\"1\">\n {textToDisplayInTooltip as React.ReactNode}\n </Text>\n }\n enabled={truncated}\n triggerRef={truncateRef as React.RefObject<HTMLButtonElement>}\n {...props}\n >\n <RefToTgphRef>{children}</RefToTgphRef>\n </Tooltip>\n );\n};\n\nexport { TooltipIfTruncated };\n","import type { TgphComponentProps, TgphElement } from \"@telegraph/helpers\";\nimport { Text } from \"@telegraph/typography\";\n\nimport { TooltipIfTruncated } from \"../TooltipIfTruncated\";\n\ntype TruncatedTextProps<T extends TgphElement> = {\n tooltipProps?: Partial<TgphComponentProps<typeof TooltipIfTruncated>>;\n} & TgphComponentProps<typeof Text<T>>;\n\nconst TruncatedText = <T extends TgphElement>({\n tooltipProps,\n style,\n ...props\n}: TruncatedTextProps<T>) => {\n return (\n <TooltipIfTruncated {...tooltipProps}>\n <Text\n textOverflow=\"ellipsis\"\n overflow=\"hidden\"\n style={{\n display: \"block\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n </TooltipIfTruncated>\n );\n};\n\nexport { TruncatedText };\n"],"names":["useTruncate","tgphRef","deps","truncated","setTruncated","React","tgphRefElement","checkTruncation","resizeObserver","TooltipIfTruncated","label","children","props","truncateRef","textToDisplayInTooltip","jsx","Tooltip","Text","RefToTgphRef","TruncatedText","tooltipProps","style"],"mappings":";;;;;AAMA,MAAMA,IAAc,CAClB,EAAE,SAAAC,KACFC,IAA6B,CAAA,MAC1B;AACH,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAM,SAAS,EAAK;AAEtD,SAAAA,EAAM,UAAU,MAAM;AACpB,QAAI,CAACJ,EAAQ,QAAS,QAAOG,EAAa,EAAK;AAE/C,UAAME,IAAiBL,EAAQ,SAEzBM,IAAkB,MAAM;AAC5B,MAAAH,EAAaE,EAAe,cAAcA,EAAe,WAAW;AAAA,IACtE;AAGA,IAAAC,EAAA;AAGA,UAAMC,IAAiB,IAAI,eAAeD,CAAe;AACzD,WAAAC,EAAe,QAAQF,CAAc,GAG9B,MAAM;AACX,MAAAE,EAAe,WAAA;AAAA,IACjB;AAAA,EAEF,GAAG,CAACP,GAAS,GAAGC,CAAI,CAAC,GAEd,EAAE,WAAAC,EAAA;AACX,GCpBMM,IAAqB,CAAC;AAAA,EAC1B,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAA+B;AAC7B,QAAMC,IAAcR,EAAM,OAA0B,IAAI,GAClD,EAAE,WAAAF,MAAcH;AAAA,IACpB,EAAE,SAASa,EAAA;AAAA,IACX,CAACF,CAAQ;AAAA,EAAA,GAILG,IAAyBT,EAAM,QAAQ,MACvC,OAAOM,KAAa,WAAiBA,IACrCN,EAAM,eAAeM,CAAQ,IACZA,EAAS,MACV,WAEbD,GACN,CAACC,GAAUD,CAAK,CAAC;AAEpB,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,OACE,gBAAAD,EAACE,GAAA,EAAK,IAAG,QAAO,MAAK,KAClB,UAAAH,GACH;AAAA,MAEF,SAASX;AAAA,MACT,YAAYU;AAAA,MACX,GAAGD;AAAA,MAEJ,UAAA,gBAAAG,EAACG,KAAc,UAAAP,EAAA,CAAS;AAAA,IAAA;AAAA,EAAA;AAG9B,GC1CMQ,IAAgB,CAAwB;AAAA,EAC5C,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGT;AACL,MAEI,gBAAAG,EAACN,GAAA,EAAoB,GAAGW,GACtB,UAAA,gBAAAL;AAAA,EAACE;AAAA,EAAA;AAAA,IACC,cAAa;AAAA,IACb,UAAS;AAAA,IACT,OAAO;AAAA,MACL,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,GAAGI;AAAA,IAAA;AAAA,IAEJ,GAAGT;AAAA,EAAA;AAAA,GAER;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/useTruncate/useTruncate.ts","../../src/TooltipIfTruncated/TooltipIfTruncated.tsx","../../src/TruncatedText/TruncatedText.tsx"],"sourcesContent":["import React from \"react\";\n\ntype UseTruncateParams = {\n tgphRef: React.RefObject<HTMLElement | null>;\n};\n\nconst useTruncate = (\n { tgphRef }: UseTruncateParams,\n deps: React.DependencyList = [],\n) => {\n const [truncated, setTruncated] = React.useState(false);\n\n React.useEffect(() => {\n if (!tgphRef.current) return setTruncated(false);\n\n const tgphRefElement = tgphRef.current;\n\n const checkTruncation = () => {\n setTruncated(tgphRefElement.scrollWidth > tgphRefElement.clientWidth);\n };\n\n // Initial check\n checkTruncation();\n\n // Add a resize observer to check for truncation when the element is resized\n const resizeObserver = new ResizeObserver(checkTruncation);\n resizeObserver.observe(tgphRefElement);\n\n // Clean up\n return () => {\n resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tgphRef, ...deps]);\n\n return { truncated };\n};\n\nexport { useTruncate };\n","import {\n type Optional,\n RefToTgphRef,\n type TgphComponentProps,\n} from \"@telegraph/helpers\";\nimport { Tooltip } from \"@telegraph/tooltip\";\nimport { Text } from \"@telegraph/typography\";\nimport React from \"react\";\n\nimport { useTruncate } from \"../useTruncate\";\n\nexport type TooltipIfTruncatedProps = Optional<\n TgphComponentProps<typeof Tooltip>,\n \"label\"\n>;\n\nconst TooltipIfTruncated = ({\n label,\n children,\n ...props\n}: TooltipIfTruncatedProps) => {\n const truncateRef = React.useRef<HTMLButtonElement>(null);\n const { truncated } = useTruncate(\n { tgphRef: truncateRef as React.RefObject<HTMLElement> },\n [children],\n );\n\n // We extract the text so that we can properly wrap it in the Text component\n const textToDisplayInTooltip = React.useMemo(() => {\n if (typeof children === \"string\") return children;\n if (React.isValidElement(children)) {\n const childProps = children.props as Record<string, unknown>;\n return childProps.children;\n }\n return label;\n }, [children, label]);\n\n return (\n <Tooltip\n label={\n <Text as=\"span\" size=\"1\">\n {textToDisplayInTooltip as React.ReactNode}\n </Text>\n }\n enabled={truncated}\n triggerRef={truncateRef as React.RefObject<HTMLButtonElement>}\n {...props}\n >\n <RefToTgphRef>{children}</RefToTgphRef>\n </Tooltip>\n );\n};\n\nexport { TooltipIfTruncated };\n","import type { TgphComponentProps, TgphElement } from \"@telegraph/helpers\";\nimport { Text } from \"@telegraph/typography\";\n\nimport { TooltipIfTruncated } from \"../TooltipIfTruncated\";\n\nexport type TruncatedTextProps<T extends TgphElement = \"span\"> = {\n tooltipProps?: Partial<TgphComponentProps<typeof TooltipIfTruncated>>;\n} & TgphComponentProps<typeof Text<T>>;\n\nconst TruncatedText = <T extends TgphElement = \"span\">({\n tooltipProps,\n style,\n ...props\n}: TruncatedTextProps<T>) => {\n return (\n <TooltipIfTruncated {...tooltipProps}>\n <Text\n textOverflow=\"ellipsis\"\n overflow=\"hidden\"\n style={{\n display: \"block\",\n whiteSpace: \"nowrap\",\n ...style,\n }}\n {...props}\n />\n </TooltipIfTruncated>\n );\n};\n\nexport { TruncatedText };\n"],"names":["useTruncate","tgphRef","deps","truncated","setTruncated","React","tgphRefElement","checkTruncation","resizeObserver","TooltipIfTruncated","label","children","props","truncateRef","textToDisplayInTooltip","jsx","Tooltip","Text","RefToTgphRef","TruncatedText","tooltipProps","style"],"mappings":";;;;;AAMA,MAAMA,IAAc,CAClB,EAAE,SAAAC,KACFC,IAA6B,CAAA,MAC1B;AACH,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAM,SAAS,EAAK;AAEtD,SAAAA,EAAM,UAAU,MAAM;AACpB,QAAI,CAACJ,EAAQ,QAAS,QAAOG,EAAa,EAAK;AAE/C,UAAME,IAAiBL,EAAQ,SAEzBM,IAAkB,MAAM;AAC5B,MAAAH,EAAaE,EAAe,cAAcA,EAAe,WAAW;AAAA,IACtE;AAGA,IAAAC,EAAA;AAGA,UAAMC,IAAiB,IAAI,eAAeD,CAAe;AACzD,WAAAC,EAAe,QAAQF,CAAc,GAG9B,MAAM;AACX,MAAAE,EAAe,WAAA;AAAA,IACjB;AAAA,EAEF,GAAG,CAACP,GAAS,GAAGC,CAAI,CAAC,GAEd,EAAE,WAAAC,EAAA;AACX,GCpBMM,IAAqB,CAAC;AAAA,EAC1B,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAA+B;AAC7B,QAAMC,IAAcR,EAAM,OAA0B,IAAI,GAClD,EAAE,WAAAF,MAAcH;AAAA,IACpB,EAAE,SAASa,EAAA;AAAA,IACX,CAACF,CAAQ;AAAA,EAAA,GAILG,IAAyBT,EAAM,QAAQ,MACvC,OAAOM,KAAa,WAAiBA,IACrCN,EAAM,eAAeM,CAAQ,IACZA,EAAS,MACV,WAEbD,GACN,CAACC,GAAUD,CAAK,CAAC;AAEpB,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,OACE,gBAAAD,EAACE,GAAA,EAAK,IAAG,QAAO,MAAK,KAClB,UAAAH,GACH;AAAA,MAEF,SAASX;AAAA,MACT,YAAYU;AAAA,MACX,GAAGD;AAAA,MAEJ,UAAA,gBAAAG,EAACG,KAAc,UAAAP,EAAA,CAAS;AAAA,IAAA;AAAA,EAAA;AAG9B,GC1CMQ,IAAgB,CAAiC;AAAA,EACrD,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGT;AACL,MAEI,gBAAAG,EAACN,GAAA,EAAoB,GAAGW,GACtB,UAAA,gBAAAL;AAAA,EAACE;AAAA,EAAA;AAAA,IACC,cAAa;AAAA,IACb,UAAS;AAAA,IACT,OAAO;AAAA,MACL,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,GAAGI;AAAA,IAAA;AAAA,IAEJ,GAAGT;AAAA,EAAA;AAAA,GAER;"}
@@ -1,6 +1,6 @@
1
1
  import { Optional, TgphComponentProps } from '@telegraph/helpers';
2
2
  import { Tooltip } from '@telegraph/tooltip';
3
- type TooltipIfTruncatedProps = Optional<TgphComponentProps<typeof Tooltip>, "label">;
3
+ export type TooltipIfTruncatedProps = Optional<TgphComponentProps<typeof Tooltip>, "label">;
4
4
  declare const TooltipIfTruncated: ({ label, children, ...props }: TooltipIfTruncatedProps) => import("react/jsx-runtime").JSX.Element;
5
5
  export { TooltipIfTruncated };
6
6
  //# sourceMappingURL=TooltipIfTruncated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipIfTruncated.d.ts","sourceRoot":"","sources":["../../../src/TooltipIfTruncated/TooltipIfTruncated.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAM7C,KAAK,uBAAuB,GAAG,QAAQ,CACrC,kBAAkB,CAAC,OAAO,OAAO,CAAC,EAClC,OAAO,CACR,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,+BAIzB,uBAAuB,4CA+BzB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"TooltipIfTruncated.d.ts","sourceRoot":"","sources":["../../../src/TooltipIfTruncated/TooltipIfTruncated.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAM7C,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAC5C,kBAAkB,CAAC,OAAO,OAAO,CAAC,EAClC,OAAO,CACR,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,+BAIzB,uBAAuB,4CA+BzB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { TooltipIfTruncated } from './TooltipIfTruncated';
2
+ export type { TooltipIfTruncatedProps } from './TooltipIfTruncated';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TooltipIfTruncated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TooltipIfTruncated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { TgphComponentProps, TgphElement } from '@telegraph/helpers';
2
2
  import { Text } from '@telegraph/typography';
3
3
  import { TooltipIfTruncated } from '../TooltipIfTruncated';
4
- type TruncatedTextProps<T extends TgphElement> = {
4
+ export type TruncatedTextProps<T extends TgphElement = "span"> = {
5
5
  tooltipProps?: Partial<TgphComponentProps<typeof TooltipIfTruncated>>;
6
6
  } & TgphComponentProps<typeof Text<T>>;
7
- declare const TruncatedText: <T extends TgphElement>({ tooltipProps, style, ...props }: TruncatedTextProps<T>) => import("react/jsx-runtime").JSX.Element;
7
+ declare const TruncatedText: <T extends TgphElement = "span">({ tooltipProps, style, ...props }: TruncatedTextProps<T>) => import("react/jsx-runtime").JSX.Element;
8
8
  export { TruncatedText };
9
9
  //# sourceMappingURL=TruncatedText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TruncatedText.d.ts","sourceRoot":"","sources":["../../../src/TruncatedText/TruncatedText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,KAAK,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACvE,GAAG,kBAAkB,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvC,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,WAAW,EAAE,mCAI3C,kBAAkB,CAAC,CAAC,CAAC,4CAevB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"TruncatedText.d.ts","sourceRoot":"","sources":["../../../src/TruncatedText/TruncatedText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,IAAI;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACvE,GAAG,kBAAkB,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvC,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,WAAW,GAAG,MAAM,EAAE,mCAIpD,kBAAkB,CAAC,CAAC,CAAC,4CAevB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { TruncatedText } from './TruncatedText';
2
+ export type { TruncatedTextProps } from './TruncatedText';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TruncatedText/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TruncatedText/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export { TooltipIfTruncated } from './TooltipIfTruncated';
2
+ export type { TooltipIfTruncatedProps } from './TooltipIfTruncated';
2
3
  export { TruncatedText } from './TruncatedText';
4
+ export type { TruncatedTextProps } from './TruncatedText';
3
5
  export { useTruncate } from './useTruncate';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telegraph/truncate",
3
- "version": "0.0.18",
3
+ "version": "0.1.0",
4
4
  "description": "Utility components for detecting and responding to content overflow, truncation, and visibility states in the UI.",
5
5
  "repository": "https://github.com/knocklabs/telegraph/tree/main/packages/truncate",
6
6
  "author": "@knocklabs",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@telegraph/helpers": "^0.0.15",
36
- "@telegraph/tooltip": "^0.0.62",
37
- "@telegraph/typography": "^0.1.29"
36
+ "@telegraph/tooltip": "^0.1.0",
37
+ "@telegraph/typography": "^0.2.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@knocklabs/eslint-config": "^0.0.5",
@@ -44,8 +44,8 @@
44
44
  "@telegraph/vite-config": "^0.0.15",
45
45
  "@types/react": "^19.2.9",
46
46
  "eslint": "^8.56.0",
47
- "react": "^19.2.3",
48
- "react-dom": "^19.2.3",
47
+ "react": "^19.2.4",
48
+ "react-dom": "^19.2.4",
49
49
  "typescript": "^5.9.3",
50
50
  "vite": "^6.4.1"
51
51
  },