@elliemae/ds-truncated-tooltip-text 3.0.0-next.0 → 3.0.0-next.4

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 (56) hide show
  1. package/dist/cjs/DSTruncatedTooltipText.js +145 -0
  2. package/dist/cjs/DSTruncatedTooltipText.js.map +7 -0
  3. package/dist/cjs/SimpleTruncatedTooltipText.js +151 -0
  4. package/dist/cjs/SimpleTruncatedTooltipText.js.map +7 -0
  5. package/dist/cjs/TooltipTextProvider.js +106 -0
  6. package/dist/cjs/TooltipTextProvider.js.map +7 -0
  7. package/dist/cjs/index.js +45 -0
  8. package/dist/cjs/index.js.map +7 -0
  9. package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +37 -0
  10. package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
  11. package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +95 -0
  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 +118 -0
  22. package/dist/esm/DSTruncatedTooltipText.js.map +7 -0
  23. package/dist/esm/SimpleTruncatedTooltipText.js +124 -0
  24. package/dist/esm/SimpleTruncatedTooltipText.js.map +7 -0
  25. package/dist/esm/TooltipTextProvider.js +79 -0
  26. package/dist/esm/TooltipTextProvider.js.map +7 -0
  27. package/dist/esm/index.js +16 -0
  28. package/dist/esm/index.js.map +7 -0
  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 +37 -27
  42. package/cjs/DSTruncateTextWithTooltip.js +0 -75
  43. package/cjs/DSTruncatedTooltipText.js +0 -112
  44. package/cjs/SimpleTruncatedTooltipText.js +0 -148
  45. package/cjs/TooltipTextProvider.js +0 -78
  46. package/cjs/index.js +0 -19
  47. package/esm/DSTruncateTextWithTooltip.js +0 -65
  48. package/esm/DSTruncatedTooltipText.js +0 -100
  49. package/esm/SimpleTruncatedTooltipText.js +0 -136
  50. package/esm/TooltipTextProvider.js +0 -64
  51. package/esm/index.js +0 -4
  52. package/types/DSTruncateTextWithTooltip.d.ts +0 -8
  53. package/types/DSTruncatedTooltipText.d.ts +0 -64
  54. package/types/SimpleTruncatedTooltipText.d.ts +0 -29
  55. package/types/TooltipTextProvider.d.ts +0 -14
  56. package/types/index.d.ts +0 -5
@@ -1,78 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _jsx2 = require('@babel/runtime/helpers/jsx');
6
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
8
- require('core-js/modules/web.dom-collections.iterator.js');
9
- require('core-js/modules/esnext.async-iterator.filter.js');
10
- require('core-js/modules/esnext.iterator.constructor.js');
11
- require('core-js/modules/esnext.iterator.filter.js');
12
- require('core-js/modules/esnext.async-iterator.for-each.js');
13
- require('core-js/modules/esnext.iterator.for-each.js');
14
- var React = require('react');
15
- var DSPopover = require('@elliemae/ds-popover');
16
- var jsxRuntime = require('react/jsx-runtime');
17
-
18
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
-
20
- var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
21
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
22
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
23
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
- var DSPopover__default = /*#__PURE__*/_interopDefaultLegacy(DSPopover);
25
-
26
- const _excluded = ["children", "tooltipDelay", "placement"];
27
-
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
- const TruncatedTooltipContext = /*#__PURE__*/React__default["default"].createContext();
32
- const {
33
- Provider
34
- } = TruncatedTooltipContext;
35
-
36
- function TooltipTextProvider(_ref) {
37
- let {
38
- children,
39
- tooltipDelay = 200,
40
- placement = 'top'
41
- } = _ref,
42
- tooltipOptions = _objectWithoutProperties__default["default"](_ref, _excluded);
43
-
44
- const {
45
- show: showTooltip,
46
- hide: hideTooltip,
47
- state: tooltipState
48
- } = DSPopover.usePopoverProviderState({
49
- delay: tooltipDelay
50
- });
51
- const [zIndex, setZIndex] = React.useState(110);
52
- const value = React.useMemo(() => ({
53
- showTooltip,
54
- hideTooltip,
55
- setZIndex
56
- }), []);
57
- return /*#__PURE__*/_jsx2__default["default"](Provider, {
58
- value: value
59
- }, void 0, children, tooltipState.visible ? /*#__PURE__*/jsxRuntime.jsx(DSPopover__default["default"], _objectSpread(_objectSpread(_objectSpread({
60
- boundaries: "window",
61
- placement: placement,
62
- showArrow: true
63
- }, tooltipOptions), tooltipState.options || {}), {}, {
64
- content: tooltipState.value,
65
- referenceEl: tooltipState.reference,
66
- style: {
67
- pointerEvents: 'none',
68
- zIndex
69
- },
70
- visible: tooltipState.visible
71
- })) : null);
72
- }
73
-
74
- TooltipTextProvider.defaultProps = {};
75
-
76
- exports.TooltipTextProvider = TooltipTextProvider;
77
- exports.TruncatedTooltipContext = TruncatedTooltipContext;
78
- exports["default"] = TooltipTextProvider;
package/cjs/index.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var TooltipTextProvider = require('./TooltipTextProvider.js');
6
- var SimpleTruncatedTooltipText = require('./SimpleTruncatedTooltipText.js');
7
- var DSTruncatedTooltipText = require('./DSTruncatedTooltipText.js');
8
- var DSTruncateTextWithTooltip = require('./DSTruncateTextWithTooltip.js');
9
-
10
-
11
-
12
- exports.TooltipTextProvider = TooltipTextProvider.TooltipTextProvider;
13
- exports.TruncatedTooltipContext = TooltipTextProvider.TruncatedTooltipContext;
14
- exports.SimpleTruncatedTooltipText = SimpleTruncatedTooltipText.SimpleTruncatedTooltipText;
15
- exports.DSTruncatedTooltipText = DSTruncatedTooltipText.DSTruncatedTooltipText;
16
- exports.TruncatedTooltipTextWithSchema = DSTruncatedTooltipText.TruncatedTooltipTextWithSchema;
17
- exports["default"] = DSTruncatedTooltipText.DSTruncatedTooltipText;
18
- exports.DSTruncateTextWithTooltip = DSTruncateTextWithTooltip.DSTruncateTextWithTooltip;
19
- exports.DSTruncateTextWithTooltipDatatestId = DSTruncateTextWithTooltip.DSTruncateTextWithTooltipDatatestId;
@@ -1,65 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
- import 'core-js/modules/web.dom-collections.iterator.js';
8
- import { useState, useMemo, useEffect } from 'react';
9
- import { DSTooltipV3 } from '@elliemae/ds-tooltip';
10
- import styled from 'styled-components';
11
- import { jsx } from 'react/jsx-runtime';
12
-
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
-
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
- const Text = /*#__PURE__*/styled.span.withConfig({
17
- componentId: "sc-1w57q5j-0"
18
- })(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;:focus{border:none;outline:none;background:", ";}"], props => props.theme.colors.brand['200']);
19
- const DSTruncateTextWithTooltipDatatestId = 'DS-TruncateTextWithTooltip';
20
- const DSTruncateTextWithTooltip = _ref => {
21
- let {
22
- text,
23
- tooltipProps = {}
24
- } = _ref;
25
- const [textWrapperEl, setTextWrapperEl] = useState(); // const textWrapperEl = useRef<HTMLSpanElement>();
26
-
27
- const [isShowingEllipsis, setIsShowingEllipsis] = useState(false); // const isShowingEllipsis = textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth;
28
-
29
- const resizeObserver = useMemo(() => new ResizeObserver(entries => {
30
- if (entries.length) {
31
- const [textWrapperEntry] = entries;
32
- const el = textWrapperEntry.target;
33
- setIsShowingEllipsis((el === null || el === void 0 ? void 0 : el.scrollWidth) > (el === null || el === void 0 ? void 0 : el.clientWidth));
34
- }
35
- }), []);
36
- useEffect(() => {
37
- if (textWrapperEl) {
38
- setIsShowingEllipsis((textWrapperEl === null || textWrapperEl === void 0 ? void 0 : textWrapperEl.scrollWidth) > (textWrapperEl === null || textWrapperEl === void 0 ? void 0 : textWrapperEl.clientWidth));
39
- resizeObserver.observe(textWrapperEl);
40
- }
41
-
42
- return () => {
43
- if (textWrapperEl) {
44
- resizeObserver.unobserve(textWrapperEl);
45
- }
46
- };
47
- }, [resizeObserver, textWrapperEl]);
48
- if (isShowingEllipsis) return /*#__PURE__*/jsx(DSTooltipV3, _objectSpread(_objectSpread({
49
- text: text
50
- }, tooltipProps), {}, {
51
- children: /*#__PURE__*/jsx(Text, {
52
- ref: setTextWrapperEl,
53
- tabIndex: 0,
54
- "data-testid": DSTruncateTextWithTooltipDatatestId,
55
- children: text
56
- })
57
- }));
58
- return /*#__PURE__*/jsx(Text, {
59
- ref: setTextWrapperEl,
60
- "data-testid": DSTruncateTextWithTooltipDatatestId,
61
- children: text
62
- });
63
- };
64
-
65
- export { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipDatatestId };
@@ -1,100 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
8
- import { useContext, useEffect } from 'react';
9
- import { PropTypes, describe } from 'react-desc';
10
- import styled from 'styled-components';
11
- import { PopperPositions } from '@elliemae/ds-popper';
12
- import { TruncatedTooltipContext } from './TooltipTextProvider.js';
13
- import { jsx } from 'react/jsx-runtime';
14
-
15
- const _excluded = ["containerProps", "value", "zIndex"];
16
-
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
-
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
-
21
- const isEllipsisActive = _ref => {
22
- let {
23
- offsetWidth,
24
- scrollWidth
25
- } = _ref;
26
- return offsetWidth < scrollWidth;
27
- }; // reduce the possibility of error showing the tooltip (text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755
28
-
29
-
30
- const Text = /*#__PURE__*/styled.span.withConfig({
31
- componentId: "sc-1olo1o7-0"
32
- })(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
33
-
34
- const DSTruncatedTooltipText = _ref2 => {
35
- let {
36
- containerProps = {},
37
- value = '',
38
- zIndex = 110
39
- } = _ref2,
40
- otherTextProps = _objectWithoutProperties(_ref2, _excluded);
41
-
42
- const tooltipContext = useContext(TruncatedTooltipContext);
43
- useEffect(() => {
44
- if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);
45
- }, [zIndex]);
46
- if (!tooltipContext) return value;
47
- const {
48
- showTooltip,
49
- hideTooltip
50
- } = tooltipContext;
51
-
52
- const handleMouseEnter = e => {
53
- const {
54
- target
55
- } = e;
56
-
57
- if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
58
- showTooltip({
59
- value,
60
- reference: target
61
- }, e);
62
- }
63
- };
64
-
65
- const handleMouseLeave = e => {
66
- hideTooltip({
67
- reference: e.target
68
- });
69
- };
70
-
71
- const handlers = showTooltip ? {
72
- onMouseEnter: handleMouseEnter,
73
- onMouseLeave: handleMouseLeave
74
- } : {};
75
- return /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, containerProps), otherTextProps), handlers), {}, {
76
- children: value
77
- }));
78
- };
79
-
80
- DSTruncatedTooltipText.defaultProps = {
81
- value: '',
82
- zIndex: 110
83
- };
84
- const truncatedTooltipTextProps = {
85
- containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
86
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Text that when truncated will trigger the tooltip interaction'),
87
- tooltipPlacement: PropTypes.oneOf([PopperPositions.AUTO_START, PopperPositions.AUTO_END, PopperPositions.AUTO, PopperPositions.TOP_START, PopperPositions.TOP, PopperPositions.TOP_END, PopperPositions.RIGHT_START, PopperPositions.RIGHT, PopperPositions.RIGHT_END, PopperPositions.BOTTOM_START, PopperPositions.BOTTOM, PopperPositions.BOTTOM_END, PopperPositions.LEFT_START, PopperPositions.LEFT, PopperPositions.LEFT_END]).description('Position of the tooltip'),
88
- tooltipDelay: PropTypes.number.description('Delay to show the tooltip'),
89
- zIndex: PropTypes.number.description('override default zIndex').defaultValue(110)
90
- };
91
- DSTruncatedTooltipText.defaultProps = {
92
- containerProps: {},
93
- value: '',
94
- tooltipPlacement: undefined,
95
- tooltipDelay: undefined
96
- };
97
- const TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);
98
- TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
99
-
100
- export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, DSTruncatedTooltipText as default };
@@ -1,136 +0,0 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
- import _jsx2 from '@babel/runtime/helpers/esm/jsx';
7
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
- import 'core-js/modules/web.dom-collections.iterator.js';
9
- import { useState, useCallback, useMemo } from 'react';
10
- import { useCancellableDelayedCallback } from '@elliemae/ds-utilities';
11
- import styled from 'styled-components';
12
- import DSPopover, { PopperPositions } from '@elliemae/ds-popover';
13
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
14
-
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
-
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
- const dsTestId = 'DS-SimpleTruncateText';
19
-
20
- const isEllipsisActive = _ref => {
21
- let {
22
- offsetWidth,
23
- scrollWidth
24
- } = _ref;
25
- return offsetWidth < scrollWidth;
26
- };
27
-
28
- const initialTooltipState = function () {
29
- let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
30
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
- return {
32
- reference: null,
33
- visible: false,
34
- value,
35
- options
36
- };
37
- }; // reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755
38
-
39
-
40
- const Text = /*#__PURE__*/styled.span.withConfig({
41
- componentId: "sc-2f4vtq-0"
42
- })(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
43
-
44
- const SimpleTruncatedTooltipText = props => {
45
- const {
46
- containerProps,
47
- tooltipDelay,
48
- placement,
49
- value,
50
- zIndex,
51
- tooltipOptions,
52
- textOptions
53
- } = props; // not using "usePopoverProviderState" because usePopoverState has memory leak issues
54
-
55
- const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));
56
- const show = useCallback(newState => {
57
- setTooltipState(_objectSpread(_objectSpread(_objectSpread({}, tooltipState), newState), {}, {
58
- visible: true
59
- }));
60
- }, [tooltipState]);
61
- const hideTooltip = useCallback(newState => {
62
- setTooltipState(_objectSpread(_objectSpread(_objectSpread({}, tooltipState), newState), {}, {
63
- visible: false
64
- }));
65
- }, [tooltipState]);
66
- const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);
67
- const handleMouseEnter = useCallback(e => {
68
- const {
69
- target
70
- } = e; // we search for the closest parent with data-testid matching this component
71
- // this is required because the target may not be this component itself
72
- // when the user gives JSX as a value.
73
- // JSX as a value is required for features like text highlight during research
74
- // wich would still allow the truncation behaviour (see tree view for example)
75
- // when the target has the test-id itself target===SimpleTruncatedTextEl
76
-
77
- const SimpleTruncatedTextEl = target.closest("[data-testid=\"".concat(dsTestId, "\"]"));
78
-
79
- if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
80
- showTooltip({
81
- value,
82
- reference: SimpleTruncatedTextEl
83
- });
84
- }
85
- }, [showTooltip, value]);
86
- const handleMouseLeave = useCallback(() => {
87
- cancelShowTooltip();
88
- hideTooltip({
89
- reference: null
90
- });
91
- }, [hideTooltip, cancelShowTooltip]);
92
- const handlers = useMemo(() => {
93
- if (!showTooltip) return {};
94
- return {
95
- onMouseEnter: handleMouseEnter,
96
- onMouseLeave: handleMouseLeave
97
- };
98
- }, [showTooltip, handleMouseEnter, handleMouseLeave]);
99
- const PurePopover = useMemo(() => /*#__PURE__*/jsx(Fragment, {
100
- children: tooltipState.visible ? /*#__PURE__*/_jsx2(DSPopover, {
101
- boundaries: "window",
102
- style: {
103
- pointerEvents: 'none',
104
- zIndex
105
- },
106
- placement: placement,
107
- content: tooltipState.value,
108
- referenceEl: tooltipState.reference,
109
- visible: tooltipState.visible,
110
- showArrow: true
111
- }) : null
112
- }), [tooltipState, placement, zIndex]);
113
- const PureText = useMemo(() => /*#__PURE__*/jsx(Fragment, {
114
- children: /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, containerProps && _objectSpread({}, containerProps)), textOptions && _objectSpread({}, textOptions)), handlers && _objectSpread({}, handlers)), {}, {
115
- "data-testid": dsTestId // this is used by mouse enter too. required to support value as JSX
116
- ,
117
- children: value
118
- }))
119
- }), [containerProps, textOptions, handlers, value]);
120
- const PureSimpleTruncatedTooltipText = useMemo(() => /*#__PURE__*/jsxs(Fragment, {
121
- children: [PureText, PurePopover]
122
- }), [PureText, PurePopover]);
123
- return PureSimpleTruncatedTooltipText;
124
- };
125
-
126
- SimpleTruncatedTooltipText.defaultProps = {
127
- containerProps: {},
128
- tooltipOptions: {},
129
- textOptions: {},
130
- value: '',
131
- placement: PopperPositions.TOP,
132
- tooltipDelay: 200,
133
- zIndex: 110
134
- };
135
-
136
- export { SimpleTruncatedTooltipText, SimpleTruncatedTooltipText as default };
@@ -1,64 +0,0 @@
1
- import _jsx2 from '@babel/runtime/helpers/esm/jsx';
2
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
- import 'core-js/modules/web.dom-collections.iterator.js';
5
- import 'core-js/modules/esnext.async-iterator.filter.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.filter.js';
8
- import 'core-js/modules/esnext.async-iterator.for-each.js';
9
- import 'core-js/modules/esnext.iterator.for-each.js';
10
- import React, { useState, useMemo } from 'react';
11
- import DSPopover, { usePopoverProviderState } from '@elliemae/ds-popover';
12
- import { jsx } from 'react/jsx-runtime';
13
-
14
- const _excluded = ["children", "tooltipDelay", "placement"];
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
- const TruncatedTooltipContext = /*#__PURE__*/React.createContext();
20
- const {
21
- Provider
22
- } = TruncatedTooltipContext;
23
-
24
- function TooltipTextProvider(_ref) {
25
- let {
26
- children,
27
- tooltipDelay = 200,
28
- placement = 'top'
29
- } = _ref,
30
- tooltipOptions = _objectWithoutProperties(_ref, _excluded);
31
-
32
- const {
33
- show: showTooltip,
34
- hide: hideTooltip,
35
- state: tooltipState
36
- } = usePopoverProviderState({
37
- delay: tooltipDelay
38
- });
39
- const [zIndex, setZIndex] = useState(110);
40
- const value = useMemo(() => ({
41
- showTooltip,
42
- hideTooltip,
43
- setZIndex
44
- }), []);
45
- return /*#__PURE__*/_jsx2(Provider, {
46
- value: value
47
- }, void 0, children, tooltipState.visible ? /*#__PURE__*/jsx(DSPopover, _objectSpread(_objectSpread(_objectSpread({
48
- boundaries: "window",
49
- placement: placement,
50
- showArrow: true
51
- }, tooltipOptions), tooltipState.options || {}), {}, {
52
- content: tooltipState.value,
53
- referenceEl: tooltipState.reference,
54
- style: {
55
- pointerEvents: 'none',
56
- zIndex
57
- },
58
- visible: tooltipState.visible
59
- })) : null);
60
- }
61
-
62
- TooltipTextProvider.defaultProps = {};
63
-
64
- export { TooltipTextProvider, TruncatedTooltipContext, TooltipTextProvider as default };
package/esm/index.js DELETED
@@ -1,4 +0,0 @@
1
- export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider.js';
2
- export { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText.js';
3
- export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, DSTruncatedTooltipText as default } from './DSTruncatedTooltipText.js';
4
- export { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipDatatestId } from './DSTruncateTextWithTooltip.js';
@@ -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,64 +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?: {
55
- [x: string]: any;
56
- containerProps?: {} | undefined;
57
- value?: string | undefined;
58
- zIndex?: number | undefined;
59
- } | undefined): JSX.Element;
60
- propTypes: unknown;
61
- toTypescript: () => import("react-desc").TypescriptSchema;
62
- };
63
- export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };
64
- 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;
package/types/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './TooltipTextProvider';
2
- export * from './SimpleTruncatedTooltipText';
3
- export * from './DSTruncatedTooltipText';
4
- export { default } from './DSTruncatedTooltipText';
5
- export * from './DSTruncateTextWithTooltip';