@elliemae/ds-truncated-tooltip-text 3.0.0-alpha.0 → 3.0.0-alpha.1

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.
Files changed (49) hide show
  1. package/dist/cjs/DSTruncatedTooltipText.js +37 -11
  2. package/dist/cjs/DSTruncatedTooltipText.js.map +1 -1
  3. package/dist/cjs/SimpleTruncatedTooltipText.js +21 -7
  4. package/dist/cjs/SimpleTruncatedTooltipText.js.map +1 -1
  5. package/dist/cjs/TooltipTextProvider.js +43 -11
  6. package/dist/cjs/TooltipTextProvider.js.map +1 -1
  7. package/dist/cjs/index.js +3 -3
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +37 -0
  10. package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
  11. package/dist/cjs/{DSTruncateTextWithTooltip.js → truncateTextWithTooltip/DSTruncateTextWithTooltip.js} +33 -24
  12. package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +7 -0
  13. package/dist/cjs/truncateTextWithTooltip/defaultProps.js +37 -0
  14. package/dist/cjs/truncateTextWithTooltip/defaultProps.js.map +7 -0
  15. package/dist/cjs/truncateTextWithTooltip/index.js +29 -0
  16. package/dist/cjs/truncateTextWithTooltip/index.js.map +7 -0
  17. package/dist/cjs/truncateTextWithTooltip/propTypes.js +39 -0
  18. package/dist/cjs/truncateTextWithTooltip/propTypes.js.map +7 -0
  19. package/dist/cjs/truncateTextWithTooltip/styles.js +47 -0
  20. package/dist/cjs/truncateTextWithTooltip/styles.js.map +7 -0
  21. package/dist/esm/DSTruncatedTooltipText.js +39 -11
  22. package/dist/esm/DSTruncatedTooltipText.js.map +1 -1
  23. package/dist/esm/SimpleTruncatedTooltipText.js +23 -7
  24. package/dist/esm/SimpleTruncatedTooltipText.js.map +1 -1
  25. package/dist/esm/TooltipTextProvider.js +45 -11
  26. package/dist/esm/TooltipTextProvider.js.map +1 -1
  27. package/dist/esm/index.js +2 -2
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +8 -0
  30. package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
  31. package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +68 -0
  32. package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +7 -0
  33. package/dist/esm/truncateTextWithTooltip/defaultProps.js +8 -0
  34. package/dist/esm/truncateTextWithTooltip/defaultProps.js.map +7 -0
  35. package/dist/esm/truncateTextWithTooltip/index.js +4 -0
  36. package/dist/esm/truncateTextWithTooltip/index.js.map +7 -0
  37. package/dist/esm/truncateTextWithTooltip/propTypes.js +10 -0
  38. package/dist/esm/truncateTextWithTooltip/propTypes.js.map +7 -0
  39. package/dist/esm/truncateTextWithTooltip/styles.js +18 -0
  40. package/dist/esm/truncateTextWithTooltip/styles.js.map +7 -0
  41. package/package.json +7 -5
  42. package/dist/cjs/DSTruncateTextWithTooltip.js.map +0 -7
  43. package/dist/esm/DSTruncateTextWithTooltip.js +0 -57
  44. package/dist/esm/DSTruncateTextWithTooltip.js.map +0 -7
  45. package/dist/types/DSTruncateTextWithTooltip.d.ts +0 -8
  46. package/dist/types/DSTruncatedTooltipText.d.ts +0 -59
  47. package/dist/types/SimpleTruncatedTooltipText.d.ts +0 -29
  48. package/dist/types/TooltipTextProvider.d.ts +0 -14
  49. package/dist/types/index.d.ts +0 -4
@@ -1,57 +0,0 @@
1
- import * as React from "react";
2
- import React2, { useState, useMemo, useEffect } from "react";
3
- import { DSTooltipV3 } from "@elliemae/ds-tooltip";
4
- import styled from "styled-components";
5
- const Text = styled.span`
6
- text-overflow: ellipsis;
7
- white-space: nowrap;
8
- overflow: hidden;
9
- display: inline-block;
10
- max-width: 100%;
11
- :focus {
12
- border: none;
13
- outline: none;
14
- background: ${(props) => props.theme.colors.brand["200"]};
15
- }
16
- `;
17
- const DSTruncateTextWithTooltipDatatestId = "DS-TruncateTextWithTooltip";
18
- const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }) => {
19
- const [textWrapperEl, setTextWrapperEl] = useState();
20
- const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
21
- const resizeObserver = useMemo(() => new ResizeObserver((entries) => {
22
- if (entries.length) {
23
- const [textWrapperEntry] = entries;
24
- const el = textWrapperEntry.target;
25
- setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
26
- }
27
- }), []);
28
- useEffect(() => {
29
- if (textWrapperEl) {
30
- setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
31
- resizeObserver.observe(textWrapperEl);
32
- }
33
- return () => {
34
- if (textWrapperEl) {
35
- resizeObserver.unobserve(textWrapperEl);
36
- }
37
- };
38
- }, [resizeObserver, textWrapperEl]);
39
- if (isShowingEllipsis)
40
- return /* @__PURE__ */ React2.createElement(DSTooltipV3, {
41
- text,
42
- ...tooltipProps
43
- }, /* @__PURE__ */ React2.createElement(Text, {
44
- ref: setTextWrapperEl,
45
- tabIndex: 0,
46
- "data-testid": DSTruncateTextWithTooltipDatatestId
47
- }, text));
48
- return /* @__PURE__ */ React2.createElement(Text, {
49
- ref: setTextWrapperEl,
50
- "data-testid": DSTruncateTextWithTooltipDatatestId
51
- }, text);
52
- };
53
- export {
54
- DSTruncateTextWithTooltip,
55
- DSTruncateTextWithTooltipDatatestId
56
- };
57
- //# sourceMappingURL=DSTruncateTextWithTooltip.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSTruncateTextWithTooltip.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useMemo, useEffect, useRef } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport styled from 'styled-components';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n :focus {\n border: none;\n outline: none;\n background: ${(props) => props.theme.colors.brand['200']};\n }\n`;\ninterface PropsT {\n text: string;\n tooltipProps?: Record<string, unknown>;\n}\nexport const DSTruncateTextWithTooltipDatatestId = 'DS-TruncateTextWithTooltip';\nexport const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }: PropsT): JSX.Element => {\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement>();\n // const textWrapperEl = useRef<HTMLSpanElement>();\n const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);\n // const isShowingEllipsis = textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth;\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (entries.length) {\n const [textWrapperEntry] = entries;\n const el = textWrapperEntry.target;\n setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);\n }\n }),\n [],\n );\n useEffect(() => {\n if (textWrapperEl) {\n setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);\n resizeObserver.observe(textWrapperEl);\n }\n return () => {\n if (textWrapperEl) {\n resizeObserver.unobserve(textWrapperEl);\n }\n };\n }, [resizeObserver, textWrapperEl]);\n\n if (isShowingEllipsis)\n return (\n <DSTooltipV3 text={text} {...tooltipProps}>\n <Text ref={setTextWrapperEl} tabIndex={0} data-testid={DSTruncateTextWithTooltipDatatestId}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestId}>\n {text}\n </Text>\n );\n};\n"],
5
- "mappings": "AAAA;ACAA;AACA;AACA;AAGA,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBASF,CAAC,UAAU,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;AAO/C,MAAM,sCAAsC;AAC5C,MAAM,4BAA4B,CAAC,EAAE,MAAM,eAAe,SAA8B;AAC7F,QAAM,CAAC,eAAe,oBAAoB;AAE1C,QAAM,CAAC,mBAAmB,wBAAwB,SAAS;AAG3D,QAAM,iBAAiB,QACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,QAAI,QAAQ,QAAQ;AAClB,YAAM,CAAC,oBAAoB;AAC3B,YAAM,KAAK,iBAAiB;AAC5B,2BAAqB,IAAI,cAAc,IAAI;AAAA;AAAA,MAGjD;AAEF,YAAU,MAAM;AACd,QAAI,eAAe;AACjB,2BAAqB,eAAe,cAAc,eAAe;AACjE,qBAAe,QAAQ;AAAA;AAEzB,WAAO,MAAM;AACX,UAAI,eAAe;AACjB,uBAAe,UAAU;AAAA;AAAA;AAAA,KAG5B,CAAC,gBAAgB;AAEpB,MAAI;AACF,WACE,qCAAC,aAAD;AAAA,MAAa;AAAA,SAAgB;AAAA,OAC3B,qCAAC,MAAD;AAAA,MAAM,KAAK;AAAA,MAAkB,UAAU;AAAA,MAAG,eAAa;AAAA,OACpD;AAKT,SACE,qCAAC,MAAD;AAAA,IAAM,KAAK;AAAA,IAAkB,eAAa;AAAA,KACvC;AAAA;",
6
- "names": []
7
- }
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- interface PropsT {
3
- text: string;
4
- tooltipProps?: Record<string, unknown>;
5
- }
6
- export declare const DSTruncateTextWithTooltipDatatestId = "DS-TruncateTextWithTooltip";
7
- export declare const DSTruncateTextWithTooltip: ({ text, tooltipProps }: PropsT) => JSX.Element;
8
- export {};
@@ -1,59 +0,0 @@
1
- /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
- /// <reference types="react" />
3
- declare const DSTruncatedTooltipText: {
4
- ({ containerProps, value, zIndex, ...otherTextProps }: {
5
- [x: string]: any;
6
- containerProps?: {} | undefined;
7
- value?: string | undefined;
8
- zIndex?: number | undefined;
9
- }): string | JSX.Element;
10
- defaultProps: {
11
- value: string;
12
- zIndex: number;
13
- containerProps?: undefined;
14
- tooltipPlacement?: undefined;
15
- tooltipDelay?: undefined;
16
- } | {
17
- containerProps: {};
18
- value: string;
19
- tooltipPlacement: undefined;
20
- tooltipDelay: undefined;
21
- zIndex?: undefined;
22
- };
23
- propTypes: {
24
- containerProps: {
25
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
26
- deprecated: import("react-desc").PropTypesDescValidator;
27
- };
28
- isRequired: import("react-desc").PropTypesDescValue;
29
- };
30
- value: {
31
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
32
- deprecated: import("react-desc").PropTypesDescValidator;
33
- };
34
- isRequired: import("react-desc").PropTypesDescValue;
35
- };
36
- tooltipPlacement: {
37
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
38
- deprecated: import("react-desc").PropTypesDescValidator;
39
- };
40
- isRequired: import("react-desc").PropTypesDescValue;
41
- };
42
- tooltipDelay: {
43
- defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
44
- deprecated: import("react-desc").PropTypesDescValidator;
45
- };
46
- isRequired: import("react-desc").PropTypesDescValue;
47
- };
48
- zIndex: {
49
- deprecated: import("react-desc").PropTypesDescValidator;
50
- };
51
- };
52
- };
53
- declare const TruncatedTooltipTextWithSchema: {
54
- (props?: unknown): JSX.Element;
55
- propTypes: unknown;
56
- toTypescript: () => import("react-desc").TypescriptSchema;
57
- };
58
- export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };
59
- export default DSTruncatedTooltipText;
@@ -1,29 +0,0 @@
1
- /// <reference types="react" />
2
- import PropTypes from 'prop-types';
3
- declare const SimpleTruncatedTooltipText: {
4
- (props: any): JSX.Element;
5
- propTypes: {
6
- containerProps: PropTypes.Requireable<object>;
7
- tooltipOptions: PropTypes.Requireable<object>;
8
- textOptions: PropTypes.Requireable<object>;
9
- /** Text that when truncated will trigger the tooltip interaction */
10
- value: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
11
- /** Position of the tooltip */
12
- placement: PropTypes.Requireable<string>;
13
- /** Delay to show the tooltip */
14
- tooltipDelay: PropTypes.Requireable<number>;
15
- /** override default zIndex */
16
- zIndex: PropTypes.Requireable<number>;
17
- };
18
- defaultProps: {
19
- containerProps: {};
20
- tooltipOptions: {};
21
- textOptions: {};
22
- value: string;
23
- placement: string;
24
- tooltipDelay: number;
25
- zIndex: number;
26
- };
27
- };
28
- export { SimpleTruncatedTooltipText };
29
- export default SimpleTruncatedTooltipText;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- declare const TruncatedTooltipContext: React.Context<unknown>;
3
- declare function TooltipTextProvider({ children, tooltipDelay, placement, ...tooltipOptions }: {
4
- [x: string]: any;
5
- children: any;
6
- tooltipDelay?: number | undefined;
7
- placement?: string | undefined;
8
- }): JSX.Element;
9
- declare namespace TooltipTextProvider {
10
- var propTypes: {};
11
- var defaultProps: {};
12
- }
13
- export { TooltipTextProvider, TruncatedTooltipContext };
14
- export default TooltipTextProvider;
@@ -1,4 +0,0 @@
1
- export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';
2
- export { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';
3
- export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';
4
- export { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from './DSTruncateTextWithTooltip';