@dxos/react-ui-text-tooltip 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44
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/dist/lib/browser/index.mjs +20 -26
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +20 -26
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -13
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
// src/components/TextTooltip.tsx
|
|
2
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
3
2
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
4
3
|
import React, { forwardRef, useCallback, useRef } from "react";
|
|
5
4
|
import { Tooltip } from "@dxos/react-ui";
|
|
6
5
|
var TextTooltip = /* @__PURE__ */ forwardRef(({ __scopeTooltip, text, children, onlyWhenTruncating, asChild = true, side, truncateQuery, ...props }, forwardedRef) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
if (!element || element.scrollWidth <= element.offsetWidth) {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
}
|
|
6
|
+
const content = useRef(null);
|
|
7
|
+
const ref = useComposedRefs(content, forwardedRef);
|
|
8
|
+
const handleInteract = useCallback((event) => {
|
|
9
|
+
if (onlyWhenTruncating && content.current) {
|
|
10
|
+
const element = truncateQuery ? content.current.querySelector(truncateQuery) : content.current;
|
|
11
|
+
if (!element || element.scrollWidth <= element.offsetWidth) {
|
|
12
|
+
event.preventDefault();
|
|
17
13
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
_effect.f();
|
|
32
|
-
}
|
|
14
|
+
}
|
|
15
|
+
}, [
|
|
16
|
+
onlyWhenTruncating,
|
|
17
|
+
truncateQuery
|
|
18
|
+
]);
|
|
19
|
+
return /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
20
|
+
asChild,
|
|
21
|
+
...props,
|
|
22
|
+
content: text,
|
|
23
|
+
side,
|
|
24
|
+
onInteract: handleInteract,
|
|
25
|
+
ref
|
|
26
|
+
}, children);
|
|
33
27
|
});
|
|
34
28
|
export {
|
|
35
29
|
TextTooltip
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/TextTooltip.tsx"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport React, {\n type ComponentPropsWithoutRef,\n type PropsWithChildren,\n type SyntheticEvent,\n forwardRef,\n useCallback,\n useRef,\n} from 'react';\n\nimport { Tooltip, type TooltipScopedProps, type TooltipTriggerProps } from '@dxos/react-ui';\n\nexport type TextTooltipProps = PropsWithChildren<\n {\n text: string;\n asChild?: boolean;\n onlyWhenTruncating?: boolean;\n truncateQuery?: string;\n } & Pick<TooltipTriggerProps, 'side'> &\n ComponentPropsWithoutRef<'button'>\n>;\n\nexport const TextTooltip = forwardRef<HTMLButtonElement, TooltipScopedProps<TextTooltipProps>>(\n (\n { __scopeTooltip, text, children, onlyWhenTruncating, asChild = true, side, truncateQuery, ...props },\n forwardedRef,\n ) => {\n const content = useRef<HTMLButtonElement | null>(null);\n const ref = useComposedRefs(content, forwardedRef);\n const handleInteract = useCallback(\n (event: SyntheticEvent) => {\n if (onlyWhenTruncating && content.current) {\n const element: HTMLElement | null = truncateQuery\n ? content.current.querySelector(truncateQuery)\n : content.current;\n if (!element || element.scrollWidth <= element.offsetWidth) {\n event.preventDefault();\n }\n }\n },\n [onlyWhenTruncating, truncateQuery],\n );\n return (\n <Tooltip.Trigger asChild={asChild} {...props} content={text} side={side} onInteract={handleInteract} ref={ref}>\n {children}\n </Tooltip.Trigger>\n );\n },\n);\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAIA,SAASA,uBAAuB;AAChC,OAAOC,SAILC,YACAC,aACAC,cACK;AAEP,SAASC,eAAkE;AAYpE,IAAMC,cAAcC,2BACzB,CACE,EAAEC,gBAAgBC,MAAMC,UAAUC,oBAAoBC,UAAU,MAAMC,MAAMC,eAAe,GAAGC,MAAAA,GAC9FC,iBAAAA;AAEA,QAAMC,UAAUC,OAAiC,IAAA;AACjD,QAAMC,MAAMC,gBAAgBH,SAASD,YAAAA;AACrC,QAAMK,iBAAiBC,YACrB,CAACC,UAAAA;AACC,QAAIZ,sBAAsBM,QAAQO,SAAS;AACzC,YAAMC,UAA8BX,gBAChCG,QAAQO,QAAQE,cAAcZ,aAAAA,IAC9BG,QAAQO;AACZ,UAAI,CAACC,WAAWA,QAAQE,eAAeF,QAAQG,aAAa;AAC1DL,cAAMM,eAAc;MACtB;IACF;EACF,GACA;IAAClB;IAAoBG;GAAc;AAErC,SACE,sBAAA,cAACgB,QAAQC,SAAO;IAACnB;IAAmB,GAAGG;IAAOE,SAASR;IAAMI;IAAYmB,YAAYX;IAAgBF;KAClGT,QAAAA;AAGP,CAAA;",
|
|
6
6
|
"names": ["useComposedRefs", "React", "forwardRef", "useCallback", "useRef", "Tooltip", "TextTooltip", "forwardRef", "__scopeTooltip", "text", "children", "onlyWhenTruncating", "asChild", "side", "truncateQuery", "props", "forwardedRef", "content", "useRef", "ref", "useComposedRefs", "handleInteract", "useCallback", "event", "current", "element", "querySelector", "scrollWidth", "offsetWidth", "preventDefault", "Tooltip", "Trigger", "onInteract"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/components/TextTooltip.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/components/TextTooltip.tsx":{"bytes":5001,"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"format":"esm"},"src/components/index.ts":{"bytes":482,"imports":[{"path":"src/components/TextTooltip.tsx","kind":"import-statement","original":"./TextTooltip"}],"format":"esm"},"src/index.ts":{"bytes":466,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2821},"dist/lib/browser/index.mjs":{"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["TextTooltip"],"entryPoint":"src/index.ts","inputs":{"src/components/TextTooltip.tsx":{"bytesInOutput":974},"src/index.ts":{"bytesInOutput":0}},"bytes":1069}}}
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/components/TextTooltip.tsx
|
|
4
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
5
4
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
6
5
|
import React, { forwardRef, useCallback, useRef } from "react";
|
|
7
6
|
import { Tooltip } from "@dxos/react-ui";
|
|
8
7
|
var TextTooltip = /* @__PURE__ */ forwardRef(({ __scopeTooltip, text, children, onlyWhenTruncating, asChild = true, side, truncateQuery, ...props }, forwardedRef) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
if (!element || element.scrollWidth <= element.offsetWidth) {
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
}
|
|
8
|
+
const content = useRef(null);
|
|
9
|
+
const ref = useComposedRefs(content, forwardedRef);
|
|
10
|
+
const handleInteract = useCallback((event) => {
|
|
11
|
+
if (onlyWhenTruncating && content.current) {
|
|
12
|
+
const element = truncateQuery ? content.current.querySelector(truncateQuery) : content.current;
|
|
13
|
+
if (!element || element.scrollWidth <= element.offsetWidth) {
|
|
14
|
+
event.preventDefault();
|
|
19
15
|
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
_effect.f();
|
|
34
|
-
}
|
|
16
|
+
}
|
|
17
|
+
}, [
|
|
18
|
+
onlyWhenTruncating,
|
|
19
|
+
truncateQuery
|
|
20
|
+
]);
|
|
21
|
+
return /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
22
|
+
asChild,
|
|
23
|
+
...props,
|
|
24
|
+
content: text,
|
|
25
|
+
side,
|
|
26
|
+
onInteract: handleInteract,
|
|
27
|
+
ref
|
|
28
|
+
}, children);
|
|
35
29
|
});
|
|
36
30
|
export {
|
|
37
31
|
TextTooltip
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/TextTooltip.tsx"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport React, {\n type ComponentPropsWithoutRef,\n type PropsWithChildren,\n type SyntheticEvent,\n forwardRef,\n useCallback,\n useRef,\n} from 'react';\n\nimport { Tooltip, type TooltipScopedProps, type TooltipTriggerProps } from '@dxos/react-ui';\n\nexport type TextTooltipProps = PropsWithChildren<\n {\n text: string;\n asChild?: boolean;\n onlyWhenTruncating?: boolean;\n truncateQuery?: string;\n } & Pick<TooltipTriggerProps, 'side'> &\n ComponentPropsWithoutRef<'button'>\n>;\n\nexport const TextTooltip = forwardRef<HTMLButtonElement, TooltipScopedProps<TextTooltipProps>>(\n (\n { __scopeTooltip, text, children, onlyWhenTruncating, asChild = true, side, truncateQuery, ...props },\n forwardedRef,\n ) => {\n const content = useRef<HTMLButtonElement | null>(null);\n const ref = useComposedRefs(content, forwardedRef);\n const handleInteract = useCallback(\n (event: SyntheticEvent) => {\n if (onlyWhenTruncating && content.current) {\n const element: HTMLElement | null = truncateQuery\n ? content.current.querySelector(truncateQuery)\n : content.current;\n if (!element || element.scrollWidth <= element.offsetWidth) {\n event.preventDefault();\n }\n }\n },\n [onlyWhenTruncating, truncateQuery],\n );\n return (\n <Tooltip.Trigger asChild={asChild} {...props} content={text} side={side} onInteract={handleInteract} ref={ref}>\n {children}\n </Tooltip.Trigger>\n );\n },\n);\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,uBAAuB;AAChC,OAAOC,SAILC,YACAC,aACAC,cACK;AAEP,SAASC,eAAkE;AAYpE,IAAMC,cAAcC,2BACzB,CACE,EAAEC,gBAAgBC,MAAMC,UAAUC,oBAAoBC,UAAU,MAAMC,MAAMC,eAAe,GAAGC,MAAAA,GAC9FC,iBAAAA;AAEA,QAAMC,UAAUC,OAAiC,IAAA;AACjD,QAAMC,MAAMC,gBAAgBH,SAASD,YAAAA;AACrC,QAAMK,iBAAiBC,YACrB,CAACC,UAAAA;AACC,QAAIZ,sBAAsBM,QAAQO,SAAS;AACzC,YAAMC,UAA8BX,gBAChCG,QAAQO,QAAQE,cAAcZ,aAAAA,IAC9BG,QAAQO;AACZ,UAAI,CAACC,WAAWA,QAAQE,eAAeF,QAAQG,aAAa;AAC1DL,cAAMM,eAAc;MACtB;IACF;EACF,GACA;IAAClB;IAAoBG;GAAc;AAErC,SACE,sBAAA,cAACgB,QAAQC,SAAO;IAACnB;IAAmB,GAAGG;IAAOE,SAASR;IAAMI;IAAYmB,YAAYX;IAAgBF;KAClGT,QAAAA;AAGP,CAAA;",
|
|
6
6
|
"names": ["useComposedRefs", "React", "forwardRef", "useCallback", "useRef", "Tooltip", "TextTooltip", "forwardRef", "__scopeTooltip", "text", "children", "onlyWhenTruncating", "asChild", "side", "truncateQuery", "props", "forwardedRef", "content", "useRef", "ref", "useComposedRefs", "handleInteract", "useCallback", "event", "current", "element", "querySelector", "scrollWidth", "offsetWidth", "preventDefault", "Tooltip", "Trigger", "onInteract"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/components/TextTooltip.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/components/TextTooltip.tsx":{"bytes":5001,"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"format":"esm"},"src/components/index.ts":{"bytes":482,"imports":[{"path":"src/components/TextTooltip.tsx","kind":"import-statement","original":"./TextTooltip"}],"format":"esm"},"src/index.ts":{"bytes":466,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2823},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["TextTooltip"],"entryPoint":"src/index.ts","inputs":{"src/components/TextTooltip.tsx":{"bytesInOutput":974},"src/index.ts":{"bytesInOutput":0}},"bytes":1162}}}
|