@telegraph/truncate 0.1.2 → 0.1.3
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 +7 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +49 -60
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@telegraph/helpers`),l=require(`@telegraph/tooltip`),u=require(`@telegraph/typography`),d=require(`react`);d=s(d);let f=require(`react/jsx-runtime`);var p=({tgphRef:e},t=[])=>{let[n,r]=d.default.useState(!1);return d.default.useEffect(()=>{if(!e.current)return r(!1);let t=e.current,n=()=>{r(t.scrollWidth>t.clientWidth)};n();let i=new ResizeObserver(n);return i.observe(t),()=>{i.disconnect()}},[e,...t]),{truncated:n}},m=({label:e,children:t,...n})=>{let r=d.default.useRef(null),{truncated:i}=p({tgphRef:r},[t]);return(0,f.jsx)(l.Tooltip,{label:(0,f.jsx)(u.Text,{as:`span`,size:`1`,children:d.default.useMemo(()=>typeof t==`string`?t:d.default.isValidElement(t)?t.props.children:e,[t,e])}),enabled:i,triggerRef:r,...n,children:(0,f.jsx)(c.RefToTgphRef,{children:t})})},h=({tooltipProps:e,style:t,...n})=>(0,f.jsx)(m,{...e,children:(0,f.jsx)(u.Text,{textOverflow:`ellipsis`,overflow:`hidden`,style:{display:`block`,whiteSpace:`nowrap`,...t},...n})});exports.TooltipIfTruncated=m,exports.TruncatedText=h,exports.useTruncate=p;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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\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"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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"],"mappings":"qsBAMA,IAAM,GACJ,CAAE,WACF,EAA6B,EAAE,GAC5B,CACH,GAAM,CAAC,EAAW,GAAgB,EAAA,QAAM,SAAS,GAAM,CAyBvD,OAvBA,EAAA,QAAM,cAAgB,CACpB,GAAI,CAAC,EAAQ,QAAS,OAAO,EAAa,GAAM,CAEhD,IAAM,EAAiB,EAAQ,QAEzB,MAAwB,CAC5B,EAAa,EAAe,YAAc,EAAe,YAAY,EAIvE,GAAiB,CAGjB,IAAM,EAAiB,IAAI,eAAe,EAAgB,CAI1D,OAHA,EAAe,QAAQ,EAAe,KAGzB,CACX,EAAe,YAAY,GAG5B,CAAC,EAAS,GAAG,EAAK,CAAC,CAEf,CAAE,YAAW,ECnBhB,GAAsB,CAC1B,QACA,WACA,GAAG,KAC0B,CAC7B,IAAM,EAAc,EAAA,QAAM,OAA0B,KAAK,CACnD,CAAE,aAAc,EACpB,CAAE,QAAS,EAA6C,CACxD,CAAC,EAAS,CACX,CAYD,OACE,EAAA,EAAA,KAAC,EAAA,QAAD,CACE,OACE,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,KAAK,aAZI,EAAA,QAAM,YAC/B,OAAO,GAAa,SAAiB,EACrC,EAAA,QAAM,eAAe,EAAS,CACb,EAAS,MACV,SAEb,EACN,CAAC,EAAU,EAAM,CAAC,CAOR,CAAA,CAET,QAAS,EACT,WAAY,EACZ,GAAI,YAEJ,EAAA,EAAA,KAAC,EAAA,aAAD,CAAe,WAAwB,CAAA,CAC/B,CAAA,ECxCR,GAAiD,CACrD,eACA,QACA,GAAG,MAGD,EAAA,EAAA,KAAC,EAAD,CAAoB,GAAI,YACtB,EAAA,EAAA,KAAC,EAAA,KAAD,CACE,aAAa,WACb,SAAS,SACT,MAAO,CACL,QAAS,QACT,WAAY,SACZ,GAAG,EACJ,CACD,GAAI,EACJ,CAAA,CACiB,CAAA"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,60 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...e
|
|
51
|
-
},
|
|
52
|
-
...r
|
|
53
|
-
}
|
|
54
|
-
) });
|
|
55
|
-
export {
|
|
56
|
-
d as TooltipIfTruncated,
|
|
57
|
-
b as TruncatedText,
|
|
58
|
-
a as useTruncate
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { RefToTgphRef as e } from "@telegraph/helpers";
|
|
2
|
+
import { Tooltip as t } from "@telegraph/tooltip";
|
|
3
|
+
import { Text as n } from "@telegraph/typography";
|
|
4
|
+
import r from "react";
|
|
5
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/useTruncate/useTruncate.ts
|
|
7
|
+
var a = ({ tgphRef: e }, t = []) => {
|
|
8
|
+
let [n, i] = r.useState(!1);
|
|
9
|
+
return r.useEffect(() => {
|
|
10
|
+
if (!e.current) return i(!1);
|
|
11
|
+
let t = e.current, n = () => {
|
|
12
|
+
i(t.scrollWidth > t.clientWidth);
|
|
13
|
+
};
|
|
14
|
+
n();
|
|
15
|
+
let r = new ResizeObserver(n);
|
|
16
|
+
return r.observe(t), () => {
|
|
17
|
+
r.disconnect();
|
|
18
|
+
};
|
|
19
|
+
}, [e, ...t]), { truncated: n };
|
|
20
|
+
}, o = ({ label: o, children: s, ...c }) => {
|
|
21
|
+
let l = r.useRef(null), { truncated: u } = a({ tgphRef: l }, [s]);
|
|
22
|
+
return /* @__PURE__ */ i(t, {
|
|
23
|
+
label: /* @__PURE__ */ i(n, {
|
|
24
|
+
as: "span",
|
|
25
|
+
size: "1",
|
|
26
|
+
children: r.useMemo(() => typeof s == "string" ? s : r.isValidElement(s) ? s.props.children : o, [s, o])
|
|
27
|
+
}),
|
|
28
|
+
enabled: u,
|
|
29
|
+
triggerRef: l,
|
|
30
|
+
...c,
|
|
31
|
+
children: /* @__PURE__ */ i(e, { children: s })
|
|
32
|
+
});
|
|
33
|
+
}, s = ({ tooltipProps: e, style: t, ...r }) => /* @__PURE__ */ i(o, {
|
|
34
|
+
...e,
|
|
35
|
+
children: /* @__PURE__ */ i(n, {
|
|
36
|
+
textOverflow: "ellipsis",
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
style: {
|
|
39
|
+
display: "block",
|
|
40
|
+
whiteSpace: "nowrap",
|
|
41
|
+
...t
|
|
42
|
+
},
|
|
43
|
+
...r
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { o as TooltipIfTruncated, s as TruncatedText, a as useTruncate };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -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\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"],"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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"],"mappings":";;;;;;AAMA,IAAM,KACJ,EAAE,cACF,IAA6B,EAAE,KAC5B;CACH,IAAM,CAAC,GAAW,KAAgB,EAAM,SAAS,GAAM;AAyBvD,QAvBA,EAAM,gBAAgB;AACpB,MAAI,CAAC,EAAQ,QAAS,QAAO,EAAa,GAAM;EAEhD,IAAM,IAAiB,EAAQ,SAEzB,UAAwB;AAC5B,KAAa,EAAe,cAAc,EAAe,YAAY;;AAIvE,KAAiB;EAGjB,IAAM,IAAiB,IAAI,eAAe,EAAgB;AAI1D,SAHA,EAAe,QAAQ,EAAe,QAGzB;AACX,KAAe,YAAY;;IAG5B,CAAC,GAAS,GAAG,EAAK,CAAC,EAEf,EAAE,cAAW;GCnBhB,KAAsB,EAC1B,UACA,aACA,GAAG,QAC0B;CAC7B,IAAM,IAAc,EAAM,OAA0B,KAAK,EACnD,EAAE,iBAAc,EACpB,EAAE,SAAS,GAA6C,EACxD,CAAC,EAAS,CACX;AAYD,QACE,kBAAC,GAAD;EACE,OACE,kBAAC,GAAD;GAAM,IAAG;GAAO,MAAK;aAZI,EAAM,cAC/B,OAAO,KAAa,WAAiB,IACrC,EAAM,eAAe,EAAS,GACb,EAAS,MACV,WAEb,GACN,CAAC,GAAU,EAAM,CAAC;GAOR,CAAA;EAET,SAAS;EACT,YAAY;EACZ,GAAI;YAEJ,kBAAC,GAAD,EAAe,aAAwB,CAAA;EAC/B,CAAA;GCxCR,KAAiD,EACrD,iBACA,UACA,GAAG,QAGD,kBAAC,GAAD;CAAoB,GAAI;WACtB,kBAAC,GAAD;EACE,cAAa;EACb,UAAS;EACT,OAAO;GACL,SAAS;GACT,YAAY;GACZ,GAAG;GACJ;EACD,GAAI;EACJ,CAAA;CACiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telegraph/truncate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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,21 +33,21 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@telegraph/helpers": "^0.0.15",
|
|
36
|
-
"@telegraph/tooltip": "^0.
|
|
36
|
+
"@telegraph/tooltip": "^0.3.0",
|
|
37
37
|
"@telegraph/typography": "^0.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@knocklabs/eslint-config": "^0.0.5",
|
|
41
41
|
"@knocklabs/typescript-config": "^0.0.2",
|
|
42
|
-
"@telegraph/postcss-config": "^0.1.
|
|
43
|
-
"@telegraph/prettier-config": "^0.0.
|
|
42
|
+
"@telegraph/postcss-config": "^0.1.2",
|
|
43
|
+
"@telegraph/prettier-config": "^0.0.8",
|
|
44
44
|
"@telegraph/vite-config": "^0.0.15",
|
|
45
45
|
"@types/react": "^19.2.9",
|
|
46
|
-
"eslint": "^10.2.
|
|
47
|
-
"react": "^19.2.
|
|
48
|
-
"react-dom": "^19.2.
|
|
49
|
-
"typescript": "^
|
|
50
|
-
"vite": "^
|
|
46
|
+
"eslint": "^10.2.1",
|
|
47
|
+
"react": "^19.2.5",
|
|
48
|
+
"react-dom": "^19.2.5",
|
|
49
|
+
"typescript": "^6.0.2",
|
|
50
|
+
"vite": "^8.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "^18.0.0 || ^19.0.0",
|