@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
@@ -0,0 +1,47 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var styles_exports = {};
29
+ __export(styles_exports, {
30
+ Text: () => Text
31
+ });
32
+ var React = __toESM(require("react"));
33
+ var import_styled_components = __toESM(require("styled-components"));
34
+ const Text = import_styled_components.default.span`
35
+ text-overflow: ellipsis;
36
+ white-space: nowrap;
37
+ overflow: hidden;
38
+ display: inline-block;
39
+ max-width: 100%;
40
+ &:focus {
41
+ border: none;
42
+ outline: none;
43
+ background: ${({ theme }) => theme.colors.brand[200]};
44
+ }
45
+ `;
46
+ module.exports = __toCommonJS(styles_exports);
47
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/truncateTextWithTooltip/styles.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import styled from 'styled-components';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nexport const 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: ${({ theme }) => theme.colors.brand[200]};\n }\n`;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,+BAAmB;AAGZ,MAAM,OAAO,iCAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAST,CAAC,EAAE,YAAY,MAAM,OAAO,MAAM;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,3 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
1
29
  import * as React from "react";
2
30
  import React2, { useContext, useEffect } from "react";
3
31
  import { describe, PropTypes } from "react-desc";
@@ -12,12 +40,16 @@ const Text = styled.span`
12
40
  display: inline-block;
13
41
  max-width: 100%;
14
42
  `;
15
- const DSTruncatedTooltipText = ({
16
- containerProps = {},
17
- value = "",
18
- zIndex = 110,
19
- ...otherTextProps
20
- }) => {
43
+ const DSTruncatedTooltipText = (_a) => {
44
+ var _b = _a, {
45
+ containerProps = {},
46
+ value = "",
47
+ zIndex = 110
48
+ } = _b, otherTextProps = __objRest(_b, [
49
+ "containerProps",
50
+ "value",
51
+ "zIndex"
52
+ ]);
21
53
  const tooltipContext = useContext(TruncatedTooltipContext);
22
54
  useEffect(() => {
23
55
  if (zIndex && tooltipContext)
@@ -39,11 +71,7 @@ const DSTruncatedTooltipText = ({
39
71
  hideTooltip({ reference: e.target });
40
72
  };
41
73
  const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
42
- return /* @__PURE__ */ React2.createElement(Text, {
43
- ...containerProps,
44
- ...otherTextProps,
45
- ...handlers
46
- }, value);
74
+ return /* @__PURE__ */ React2.createElement(Text, __spreadValues(__spreadValues(__spreadValues({}, containerProps), otherTextProps), handlers), value);
47
75
  };
48
76
  DSTruncatedTooltipText.defaultProps = {
49
77
  value: "",
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSTruncatedTooltipText.tsx"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport styled from 'styled-components';\nimport { PopperPositions as positions } from '@elliemae/ds-popper';\nimport { TruncatedTooltipContext } from './TooltipTextProvider';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) =>\n offsetWidth < scrollWidth;\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`;\n\nconst DSTruncatedTooltipText = ({\n containerProps = {},\n value = '',\n zIndex = 110, // https://jira.elliemae.io/browse/PUI-1755\n ...otherTextProps\n}) => {\n const tooltipContext = useContext(TruncatedTooltipContext);\n useEffect(() => {\n if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);\n }, [zIndex]);\n\n if (!tooltipContext) return value;\n\n const { showTooltip, hideTooltip } = tooltipContext;\n\n const handleMouseEnter = (e) => {\n const { target } = e;\n if (target && isEllipsisActive(target, target.getBoundingClientRect())) {\n showTooltip(\n {\n value,\n reference: target,\n },\n e,\n );\n }\n };\n\n const handleMouseLeave = (e) => {\n hideTooltip({ reference: e.target });\n };\n\n const handlers = showTooltip\n ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }\n : {};\n return (\n <Text {...containerProps} {...otherTextProps} {...handlers}>\n {value}\n </Text>\n );\n};\n\nDSTruncatedTooltipText.defaultProps = {\n value: '',\n zIndex: 110,\n};\n\nconst truncatedTooltipTextProps = {\n containerProps: PropTypes.object.description(\n 'Set of Properties attached to the main container',\n ),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Text that when truncated will trigger the tooltip interaction',\n ),\n tooltipPlacement: PropTypes.oneOf([\n positions.AUTO_START,\n positions.AUTO_END,\n positions.AUTO,\n positions.TOP_START,\n positions.TOP,\n positions.TOP_END,\n positions.RIGHT_START,\n positions.RIGHT,\n positions.RIGHT_END,\n positions.BOTTOM_START,\n positions.BOTTOM,\n positions.BOTTOM_END,\n positions.LEFT_START,\n positions.LEFT,\n positions.LEFT_END,\n ]).description('Position of the tooltip'),\n tooltipDelay: PropTypes.number.description('Delay to show the tooltip'),\n zIndex: PropTypes.number\n .description('override default zIndex')\n .defaultValue(110),\n};\n\nDSTruncatedTooltipText.defaultProps = {\n containerProps: {},\n value: '',\n tooltipPlacement: undefined,\n tooltipDelay: undefined,\n};\n\nDSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;\n\nconst TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);\nTruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;\n\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };\nexport default DSTruncatedTooltipText;\n"],
5
- "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB,CAAC,EAAE,aAAa,kBACvC,cAAc;AAGhB,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,MAAM,yBAAyB,CAAC;AAAA,EAC9B,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,SAAS;AAAA,KACN;AAAA,MACC;AACJ,QAAM,iBAAiB,WAAW;AAClC,YAAU,MAAM;AACd,QAAI,UAAU;AAAgB,qBAAe,UAAU;AAAA,KACtD,CAAC;AAEJ,MAAI,CAAC;AAAgB,WAAO;AAE5B,QAAM,EAAE,aAAa,gBAAgB;AAErC,QAAM,mBAAmB,CAAC,MAAM;AAC9B,UAAM,EAAE,WAAW;AACnB,QAAI,UAAU,iBAAiB,QAAQ,OAAO,0BAA0B;AACtE,kBACE;AAAA,QACE;AAAA,QACA,WAAW;AAAA,SAEb;AAAA;AAAA;AAKN,QAAM,mBAAmB,CAAC,MAAM;AAC9B,gBAAY,EAAE,WAAW,EAAE;AAAA;AAG7B,QAAM,WAAW,cACb,EAAE,cAAc,kBAAkB,cAAc,qBAChD;AACJ,SACE,qCAAC,MAAD;AAAA,OAAU;AAAA,OAAoB;AAAA,OAAoB;AAAA,KAC/C;AAAA;AAKP,uBAAuB,eAAe;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ;AAAA;AAGV,MAAM,4BAA4B;AAAA,EAChC,gBAAgB,UAAU,OAAO,YAC/B;AAAA,EAEF,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAC/D;AAAA,EAEF,kBAAkB,UAAU,MAAM;AAA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W;AAAA,SAEb;AAAA;AAAA;AAKN,QAAM,mBAAmB,CAAC,MAAM;AAC9B,gBAAY,EAAE,WAAW,EAAE;AAAA;AAG7B,QAAM,WAAW,cACb,EAAE,cAAc,kBAAkB,cAAc,qBAChD;AACJ,SACE,qCAAC,MAAD,iDAAU,iBAAoB,iBAAoB,WAC/C;AAAA;AAKP,uBAAuB,eAAe;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ;AAAA;AAGV,MAAM,4BAA4B;AAAA,EAChC,gBAAgB,UAAU,OAAO,YAC/B;AAAA,EAEF,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAC/D;AAAA,EAEF,kBAAkB,UAAU,MAAM;AAAA,IAChC,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,KACT,YAAY;AAAA,EACf,cAAc,UAAU,OAAO,YAAY;AAAA,EAC3C,QAAQ,UAAU,OACf,YAAY,2BACZ,aAAa;AAAA;AAGlB,uBAAuB,eAAe;AAAA,EACpC,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAAA;AAGhB,uBAAuB,YAAY;AAEnC,MAAM,iCAAiC,SAAS;AAChD,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
20
  import * as React from "react";
2
21
  import React2, { useCallback, useMemo, useState } from "react";
3
22
  import { useCancellableDelayedCallback } from "@elliemae/ds-utilities";
@@ -23,10 +42,10 @@ const SimpleTruncatedTooltipText = (props) => {
23
42
  const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
24
43
  const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));
25
44
  const show = useCallback((newState) => {
26
- setTooltipState({ ...tooltipState, ...newState, visible: true });
45
+ setTooltipState(__spreadProps(__spreadValues(__spreadValues({}, tooltipState), newState), { visible: true }));
27
46
  }, [tooltipState]);
28
47
  const hideTooltip = useCallback((newState) => {
29
- setTooltipState({ ...tooltipState, ...newState, visible: false });
48
+ setTooltipState(__spreadProps(__spreadValues(__spreadValues({}, tooltipState), newState), { visible: false }));
30
49
  }, [tooltipState]);
31
50
  const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);
32
51
  const handleMouseEnter = useCallback((e) => {
@@ -57,12 +76,9 @@ const SimpleTruncatedTooltipText = (props) => {
57
76
  visible: tooltipState.visible,
58
77
  showArrow: true
59
78
  }) : null), [tooltipState, placement, zIndex]);
60
- const PureText = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text, {
61
- ...containerProps && { ...containerProps },
62
- ...textOptions && { ...textOptions },
63
- ...handlers && { ...handlers },
79
+ const PureText = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text, __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, containerProps && __spreadValues({}, containerProps)), textOptions && __spreadValues({}, textOptions)), handlers && __spreadValues({}, handlers)), {
64
80
  "data-testid": dsTestId
65
- }, value)), [containerProps, textOptions, handlers, value]);
81
+ }), value)), [containerProps, textOptions, handlers, value]);
66
82
  const PureSimpleTruncatedTooltipText = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, PureText, PurePopover), [PureText, PurePopover]);
67
83
  return PureSimpleTruncatedTooltipText;
68
84
  };
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/SimpleTruncatedTooltipText.tsx"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { useCancellableDelayedCallback } from '@elliemae/ds-utilities';\nimport PropTypes from 'prop-types';\nimport styled from 'styled-components';\nimport { DSPopover, PopperPositions as positions } from '@elliemae/ds-popover';\n\nconst dsTestId = 'DS-SimpleTruncateText';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;\n\nconst initialTooltipState = (value = '', options = {}) => ({\n reference: null,\n visible: false,\n value,\n options,\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`;\n\nconst SimpleTruncatedTooltipText = (props) => {\n const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;\n\n // not using \"usePopoverProviderState\" because usePopoverState has memory leak issues\n const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));\n const show = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: true });\n },\n [tooltipState],\n );\n const hideTooltip = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: false });\n },\n [tooltipState],\n );\n const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);\n\n const handleMouseEnter = useCallback(\n (e) => {\n const { target } = e;\n // we search for the closest parent with data-testid matching this component\n // this is required because the target may not be this component itself\n // when the user gives JSX as a value.\n // JSX as a value is required for features like text highlight during research\n // wich would still allow the truncation behaviour (see tree view for example)\n // when the target has the test-id itself target===SimpleTruncatedTextEl\n const SimpleTruncatedTextEl = target.closest(`[data-testid=\"${dsTestId}\"]`);\n if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {\n showTooltip({ value, reference: SimpleTruncatedTextEl });\n }\n },\n [showTooltip, value],\n );\n\n const handleMouseLeave = useCallback(() => {\n cancelShowTooltip();\n hideTooltip({ reference: null });\n }, [hideTooltip, cancelShowTooltip]);\n\n const handlers = useMemo(() => {\n if (!showTooltip) return {};\n return {\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n };\n }, [showTooltip, handleMouseEnter, handleMouseLeave]);\n\n const PurePopover = useMemo(\n () => (\n <>\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n style={{ pointerEvents: 'none', zIndex }}\n placement={placement}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n visible={tooltipState.visible}\n showArrow\n />\n ) : null}\n </>\n ),\n [tooltipState, placement, zIndex],\n );\n const PureText = useMemo(\n () => (\n <>\n <Text\n {...(containerProps && { ...containerProps })}\n {...(textOptions && { ...textOptions })}\n {...(handlers && { ...handlers })}\n data-testid={dsTestId} // this is used by mouse enter too. required to support value as JSX\n >\n {value}\n </Text>\n </>\n ),\n [containerProps, textOptions, handlers, value],\n );\n\n const PureSimpleTruncatedTooltipText = useMemo(\n () => (\n <>\n {PureText}\n {PurePopover}\n </>\n ),\n [PureText, PurePopover],\n );\n\n return PureSimpleTruncatedTooltipText;\n};\n\nSimpleTruncatedTooltipText.propTypes = {\n containerProps: PropTypes.object,\n tooltipOptions: PropTypes.object,\n textOptions: PropTypes.object,\n /** Text that when truncated will trigger the tooltip interaction */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),\n /** Position of the tooltip */\n placement: PropTypes.oneOf([\n positions.AUTO_START,\n positions.AUTO_END,\n positions.AUTO,\n positions.TOP_START,\n positions.TOP,\n positions.TOP_END,\n positions.RIGHT_START,\n positions.RIGHT,\n positions.RIGHT_END,\n positions.BOTTOM_START,\n positions.BOTTOM,\n positions.BOTTOM_END,\n positions.LEFT_START,\n positions.LEFT,\n positions.LEFT_END,\n ]),\n /** Delay to show the tooltip */\n tooltipDelay: PropTypes.number,\n /** override default zIndex */\n zIndex: PropTypes.number,\n};\n\nSimpleTruncatedTooltipText.defaultProps = {\n containerProps: {},\n tooltipOptions: {},\n textOptions: {},\n value: '',\n placement: positions.TOP,\n tooltipDelay: 200,\n zIndex: 110,\n};\n\nexport { SimpleTruncatedTooltipText };\nexport default SimpleTruncatedTooltipText;\n"],
5
- "mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AAEA,MAAM,WAAW;AAEjB,MAAM,mBAAmB,CAAC,EAAE,aAAa,kBAAkB,cAAc;AAEzE,MAAM,sBAAsB,CAAC,QAAQ,IAAI,UAAU,OAAQ;AAAA,EACzD,WAAW;AAAA,EACX,SAAS;AAAA,EACT;AAAA,EACA;AAAA;AAGF,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,MAAM,6BAA6B,CAAC,UAAU;AAC5C,QAAM,EAAE,gBAAgB,cAAc,WAAW,OAAO,QAAQ,gBAAgB,gBAAgB;AAGhG,QAAM,CAAC,cAAc,mBAAmB,SAAS,oBAAoB,OAAO;AAC5E,QAAM,OAAO,YACX,CAAC,aAAa;AACZ,oBAAgB,KAAK,iBA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AA,EAE1E,WAAW,UAAU,MAAM;AAAA,IACzB,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA;AAAA,EAGZ,cAAc,UAAU;AAAA,EAExB,QAAQ,UAAU;AAAA;AAGpB,2BAA2B,eAAe;AAAA,EACxC,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,OAAO;AAAA,EACP,WAAW,UAAU;AAAA,EACrB,cAAc;AAAA,EACd,QAAQ;AAAA;AAIV,IAAO,qCAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,14 +1,49 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
1
32
  import * as React from "react";
2
33
  import React2, { useMemo, useState } from "react";
3
34
  import { DSPopover, usePopoverProviderState } from "@elliemae/ds-popover";
4
35
  const TruncatedTooltipContext = React2.createContext();
5
36
  const { Provider } = TruncatedTooltipContext;
6
- function TooltipTextProvider({
7
- children,
8
- tooltipDelay = 200,
9
- placement = "top",
10
- ...tooltipOptions
11
- }) {
37
+ function TooltipTextProvider(_a) {
38
+ var _b = _a, {
39
+ children,
40
+ tooltipDelay = 200,
41
+ placement = "top"
42
+ } = _b, tooltipOptions = __objRest(_b, [
43
+ "children",
44
+ "tooltipDelay",
45
+ "placement"
46
+ ]);
12
47
  const {
13
48
  show: showTooltip,
14
49
  hide: hideTooltip,
@@ -22,17 +57,16 @@ function TooltipTextProvider({
22
57
  }), []);
23
58
  return /* @__PURE__ */ React2.createElement(Provider, {
24
59
  value
25
- }, children, tooltipState.visible ? /* @__PURE__ */ React2.createElement(DSPopover, {
60
+ }, children, tooltipState.visible ? /* @__PURE__ */ React2.createElement(DSPopover, __spreadProps(__spreadValues(__spreadValues({
26
61
  boundaries: "window",
27
62
  placement,
28
- showArrow: true,
29
- ...tooltipOptions,
30
- ...tooltipState.options || {},
63
+ showArrow: true
64
+ }, tooltipOptions), tooltipState.options || {}), {
31
65
  content: tooltipState.value,
32
66
  referenceEl: tooltipState.reference,
33
67
  style: { pointerEvents: "none", zIndex },
34
68
  visible: tooltipState.visible
35
- }) : null);
69
+ })) : null);
36
70
  }
37
71
  TooltipTextProvider.propTypes = {};
38
72
  TooltipTextProvider.defaultProps = {};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TooltipTextProvider.tsx"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useMemo, useState } from 'react';\nimport { DSPopover, usePopoverProviderState } from '@elliemae/ds-popover';\n\nconst TruncatedTooltipContext = React.createContext();\n\nconst { Provider } = TruncatedTooltipContext;\n\nfunction TooltipTextProvider({\n children,\n tooltipDelay = 200,\n placement = 'top',\n ...tooltipOptions\n}) {\n const {\n show: showTooltip,\n hide: hideTooltip,\n state: tooltipState,\n } = usePopoverProviderState({ delay: tooltipDelay });\n const [zIndex, setZIndex] = useState(110);\n\n const value = useMemo(\n () => ({\n showTooltip,\n hideTooltip,\n setZIndex,\n }),\n [],\n );\n\n return (\n <Provider value={value}>\n {children}\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n placement={placement}\n showArrow\n {...tooltipOptions}\n {...(tooltipState.options || {})}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n style={{ pointerEvents: 'none', zIndex }}\n visible={tooltipState.visible}\n />\n ) : null}\n </Provider>\n );\n}\n\nTooltipTextProvider.propTypes = {};\nTooltipTextProvider.defaultProps = {};\n\nexport { TooltipTextProvider, TruncatedTooltipContext };\nexport default TooltipTextProvider;\n"],
5
- "mappings": "AAAA;ACCA;AACA;AAEA,MAAM,0BAA0B,OAAM;AAEtC,MAAM,EAAE,aAAa;AAErB,6BAA6B;AAAA,EAC3B;AAAA,EACA,eAAe;AAAA,EACf,YAAY;AAAA,KACT;AAAA,GACF;AACD,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,MACL,wBAAwB,EAAE,OAAO;AACrC,QAAM,CAAC,QAAQ,aAAa,SAAS;AAErC,QAAM,QAAQ,QACZ,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAGF,SACE,qCAAC,UAAD;AAAA,IAAU;AAAA,KACP,UACA,aAAa,UACZ,qCAAC,WAAD;AAAA,IACE,YAAW;AAAA,IACX;AAAA,IACA,WAAS;AAAA,OACL;AAAA,OACC,aAAa,WAAW;AAAA,IAC7B,SAAS,aAAa;AAAA,IACtB,aAAa,aAAa;AAAA,IAC1B,OAAO,EAAE,eAAe,QAAQ;AAAA,IAChC,SAAS,aAAa;AAAA,OAEtB;AAAA;AAKV,oBAAoB,YAAY;AAChC,oBAAoB,eAAe;AAGnC,IAAO,8BAAQ;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAEA,MAAM,0BAA0B,OAAM;AAEtC,MAAM,EAAE,aAAa;AAErB,6BAA6B,IAK1B;AAL0B,eAC3B;AAAA;AAAA,IACA,eAAe;AAAA,IACf,YAAY;AAAA,MAHe,IAIxB,2BAJwB,IAIxB;AAAA,IAHH;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,MACL,wBAAwB,EAAE,OAAO;AACrC,QAAM,CAAC,QAAQ,aAAa,SAAS;AAErC,QAAM,QAAQ,QACZ,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAGF,SACE,qCAAC,UAAD;AAAA,IAAU;AAAA,KACP,UACA,aAAa,UACZ,qCAAC,WAAD;AAAA,IACE,YAAW;AAAA,IACX;AAAA,IACA,WAAS;AAAA,KACL,iBACC,aAAa,WAAW,KAL/B;AAAA,IAME,SAAS,aAAa;AAAA,IACtB,aAAa,aAAa;AAAA,IAC1B,OAAO,EAAE,eAAe,QAAQ;AAAA,IAChC,SAAS,aAAa;AAAA,QAEtB;AAAA;AAKV,oBAAoB,YAAY;AAChC,oBAAoB,eAAe;AAGnC,IAAO,8BAAQ;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -2,10 +2,10 @@ import * as React from "react";
2
2
  import { TooltipTextProvider, TruncatedTooltipContext } from "./TooltipTextProvider";
3
3
  import { SimpleTruncatedTooltipText } from "./SimpleTruncatedTooltipText";
4
4
  import { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default as default2 } from "./DSTruncatedTooltipText";
5
- import { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from "./DSTruncateTextWithTooltip";
5
+ import { DSTruncateTextWithTooltipDatatestid, DSTruncateTextWithTooltip } from "./truncateTextWithTooltip";
6
6
  export {
7
7
  DSTruncateTextWithTooltip,
8
- DSTruncateTextWithTooltipDatatestId,
8
+ DSTruncateTextWithTooltipDatatestid,
9
9
  DSTruncatedTooltipText,
10
10
  SimpleTruncatedTooltipText,
11
11
  TooltipTextProvider,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';\nexport { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';\nexport { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from './DSTruncateTextWithTooltip';\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';\nexport { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';\nexport { DSTruncateTextWithTooltipDatatestid, DSTruncateTextWithTooltip } from './truncateTextWithTooltip';\n"],
5
5
  "mappings": "AAAA;ACAA;AACA;AACA;AACA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ const DSTruncateTextWithTooltipDatatestid = {
3
+ TEXT: "ds-truncatetextwithtooltip-text"
4
+ };
5
+ export {
6
+ DSTruncateTextWithTooltipDatatestid
7
+ };
8
+ //# sourceMappingURL=DSTruncateTextWIthTooltipDatatestid.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSTruncateTextWithTooltipDatatestid = {\n TEXT: 'ds-truncatetextwithtooltip-text',\n};\n"],
5
+ "mappings": "AAAA;ACAO,MAAM,sCAAsC;AAAA,EACjD,MAAM;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import * as React from "react";
18
+ import React2, { useState, useMemo, useEffect } from "react";
19
+ import { DSTooltipV3 } from "@elliemae/ds-tooltip";
20
+ import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from "@elliemae/ds-props-helpers";
21
+ import { defaultProps } from "./defaultProps";
22
+ import { DSTruncateTextWithTooltipDatatestid } from "./DSTruncateTextWIthTooltipDatatestid";
23
+ import { propTypes } from "./propTypes";
24
+ import { Text } from "./styles";
25
+ const DSTruncateTextWithTooltip = (props) => {
26
+ const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
27
+ useValidateTypescriptPropTypes(propsWithDefault, propTypes);
28
+ const { text, tooltipProps } = propsWithDefault;
29
+ const [textWrapperEl, setTextWrapperEl] = useState(null);
30
+ const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
31
+ const resizeObserver = useMemo(() => new ResizeObserver((entries) => {
32
+ if (entries.length) {
33
+ const [textWrapperEntry] = entries;
34
+ const el = textWrapperEntry.target;
35
+ setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
36
+ }
37
+ }), []);
38
+ useEffect(() => {
39
+ if (textWrapperEl) {
40
+ setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
41
+ resizeObserver.observe(textWrapperEl);
42
+ }
43
+ return () => {
44
+ if (textWrapperEl) {
45
+ resizeObserver.unobserve(textWrapperEl);
46
+ }
47
+ };
48
+ }, [resizeObserver, textWrapperEl]);
49
+ if (isShowingEllipsis)
50
+ return /* @__PURE__ */ React2.createElement(DSTooltipV3, __spreadValues({
51
+ text
52
+ }, tooltipProps), /* @__PURE__ */ React2.createElement(Text, {
53
+ ref: setTextWrapperEl,
54
+ tabIndex: 0,
55
+ "data-testid": DSTruncateTextWithTooltipDatatestid.TEXT
56
+ }, text));
57
+ return /* @__PURE__ */ React2.createElement(Text, {
58
+ ref: setTextWrapperEl,
59
+ "data-testid": DSTruncateTextWithTooltipDatatestid.TEXT
60
+ }, text);
61
+ };
62
+ const DSTruncateTextWithTooltipWithSchema = describe(DSTruncateTextWithTooltip);
63
+ DSTruncateTextWithTooltipWithSchema.propTypes = propTypes;
64
+ export {
65
+ DSTruncateTextWithTooltip,
66
+ DSTruncateTextWithTooltipWithSchema
67
+ };
68
+ //# sourceMappingURL=DSTruncateTextWithTooltip.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/DSTruncateTextWithTooltip.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useMemo, useEffect } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from '@elliemae/ds-props-helpers';\nimport { defaultProps } from './defaultProps';\nimport { DSTruncateTextWithTooltipDatatestid } from './DSTruncateTextWIthTooltipDatatestid';\nimport { propTypes } from './propTypes';\nimport { Text } from './styles';\nimport type { DSTruncateTextWithTooltipT } from './propTypes';\n\nconst DSTruncateTextWithTooltip = (props: DSTruncateTextWithTooltipT.Props): JSX.Element => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTruncateTextWithTooltipT.Props>(props, defaultProps);\n\n useValidateTypescriptPropTypes(propsWithDefault, propTypes);\n\n const { text, tooltipProps } = propsWithDefault;\n\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement | null>(null);\n const [isShowingEllipsis, setIsShowingEllipsis] = useState<boolean>(false);\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\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.TEXT}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestid.TEXT}>\n {text}\n </Text>\n );\n};\n\nconst DSTruncateTextWithTooltipWithSchema = describe<DSTruncateTextWithTooltipT.Props>(DSTruncateTextWithTooltip);\n\nDSTruncateTextWithTooltipWithSchema.propTypes = propTypes;\n\nexport { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,4BAA4B,CAAC,UAAyD;AAC1F,QAAM,mBAAmB,6BAA+D,OAAO;AAE/F,iCAA+B,kBAAkB;AAEjD,QAAM,EAAE,MAAM,iBAAiB;AAE/B,QAAM,CAAC,eAAe,oBAAoB,SAAiC;AAC3E,QAAM,CAAC,mBAAmB,wBAAwB,SAAkB;AAEpE,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;AAGF,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,OAAgB,eAC3B,qCAAC,MAAD;AAAA,MAAM,KAAK;AAAA,MAAkB,UAAU;AAAA,MAAG,eAAa,oCAAoC;AAAA,OACxF;AAKT,SACE,qCAAC,MAAD;AAAA,IAAM,KAAK;AAAA,IAAkB,eAAa,oCAAoC;AAAA,KAC3E;AAAA;AAKP,MAAM,sCAAsC,SAA2C;AAEvF,oCAAoC,YAAY;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ const defaultProps = {
3
+ tooltipProps: {}
4
+ };
5
+ export {
6
+ defaultProps
7
+ };
8
+ //# sourceMappingURL=defaultProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/defaultProps.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSTruncateTextWithTooltipT } from './propTypes';\n\nexport const defaultProps: DSTruncateTextWithTooltipT.DefaultProps = {\n tooltipProps: {},\n};\n"],
5
+ "mappings": "AAAA;ACEO,MAAM,eAAwD;AAAA,EACnE,cAAc;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ export * from "./DSTruncateTextWithTooltip";
3
+ export * from "./DSTruncateTextWIthTooltipDatatestid";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSTruncateTextWithTooltip';\nexport * from './DSTruncateTextWIthTooltipDatatestid';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { PropTypes } from "@elliemae/ds-props-helpers";
3
+ const propTypes = {
4
+ text: PropTypes.string.description("Text to show.").isRequired,
5
+ tooltipProps: PropTypes.object.description("This component uses DSTooltip component, you can set properties directly to this component with this property.").defaultValue({})
6
+ };
7
+ export {
8
+ propTypes
9
+ };
10
+ //# sourceMappingURL=propTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/propTypes.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-len */\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSTruncateTextWithTooltipT {\n export interface PropsRequired {\n text: string;\n }\n\n export interface DefaultProps {\n tooltipProps: Record<string, unknown>;\n }\n\n export interface Props extends DefaultProps, PropsRequired {}\n}\n\nexport const propTypes = {\n text: PropTypes.string.description('Text to show.').isRequired,\n tooltipProps: PropTypes.object\n .description(\n 'This component uses DSTooltip component, you can set properties directly to this component with this property.',\n )\n .defaultValue({}),\n};\n"],
5
+ "mappings": "AAAA;ACCA;AAcO,MAAM,YAAY;AAAA,EACvB,MAAM,UAAU,OAAO,YAAY,iBAAiB;AAAA,EACpD,cAAc,UAAU,OACrB,YACC,kHAED,aAAa;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import styled from "styled-components";
3
+ const Text = styled.span`
4
+ text-overflow: ellipsis;
5
+ white-space: nowrap;
6
+ overflow: hidden;
7
+ display: inline-block;
8
+ max-width: 100%;
9
+ &:focus {
10
+ border: none;
11
+ outline: none;
12
+ background: ${({ theme }) => theme.colors.brand[200]};
13
+ }
14
+ `;
15
+ export {
16
+ Text
17
+ };
18
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/styles.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nexport const 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: ${({ theme }) => theme.colors.brand[200]};\n }\n`;\n"],
5
+ "mappings": "AAAA;ACAA;AAGO,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAST,CAAC,EAAE,YAAY,MAAM,OAAO,MAAM;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-truncated-tooltip-text",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Truncated Tooltip Text",
6
6
  "files": [
@@ -51,10 +51,11 @@
51
51
  "indent": 4
52
52
  },
53
53
  "dependencies": {
54
- "@elliemae/ds-popover": "3.0.0-alpha.0",
55
- "@elliemae/ds-popper": "3.0.0-alpha.0",
56
- "@elliemae/ds-tooltip": "3.0.0-alpha.0",
57
- "@elliemae/ds-utilities": "3.0.0-alpha.0",
54
+ "@elliemae/ds-popover": "3.0.0-alpha.1",
55
+ "@elliemae/ds-popper": "3.0.0-alpha.1",
56
+ "@elliemae/ds-props-helpers": "3.0.0-alpha.1",
57
+ "@elliemae/ds-tooltip": "3.0.0-alpha.1",
58
+ "@elliemae/ds-utilities": "3.0.0-alpha.1",
58
59
  "prop-types": "~15.7.2",
59
60
  "react-desc": "~4.1.3"
60
61
  },
@@ -74,6 +75,7 @@
74
75
  "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
75
76
  "test": "node ../../scripts/testing/test.mjs",
76
77
  "lint": "node ../../scripts/lint.mjs",
78
+ "dts": "node ../../scripts/dts.mjs",
77
79
  "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
78
80
  }
79
81
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/DSTruncateTextWithTooltip.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4D;AAC5D,wBAA4B;AAC5B,+BAAmB;AAGnB,MAAM,OAAO,iCAAO;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,2BAAS;AAG3D,QAAM,iBAAiB,0BACrB,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,8BAAU,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,mDAAC,+BAAD;AAAA,MAAa;AAAA,SAAgB;AAAA,OAC3B,mDAAC,MAAD;AAAA,MAAM,KAAK;AAAA,MAAkB,UAAU;AAAA,MAAG,eAAa;AAAA,OACpD;AAKT,SACE,mDAAC,MAAD;AAAA,IAAM,KAAK;AAAA,IAAkB,eAAa;AAAA,KACvC;AAAA;",
6
- "names": []
7
- }