@elliemae/ds-truncated-expandable-text 1.60.0 → 2.0.0-alpha.12

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.
@@ -2,68 +2,66 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _extends = require('@babel/runtime/helpers/extends');
6
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
- var React = require('react');
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ require('core-js/modules/web.dom-collections.iterator.js');
7
+ require('core-js/modules/esnext.async-iterator.for-each.js');
8
+ require('core-js/modules/esnext.iterator.constructor.js');
9
+ require('core-js/modules/esnext.iterator.for-each.js');
10
+ require('core-js/modules/esnext.async-iterator.filter.js');
11
+ require('core-js/modules/esnext.iterator.filter.js');
12
+ var react = require('react');
8
13
  var reactDesc = require('react-desc');
9
14
  var styled = require('styled-components');
10
15
  var props = require('./props.js');
11
16
  var defaultProps = require('./defaultProps.js');
17
+ var jsxRuntime = require('react/jsx-runtime');
12
18
 
13
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
20
 
15
- var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
16
- var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
17
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
18
22
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
19
23
 
20
- var Text = /*#__PURE__*/styled__default['default'].span.withConfig({
21
- componentId: "sc-1wjt65j-0"
22
- })(["text-overflow:ellipsis;white-space:", ";overflow:hidden;display:", ";-webkit-line-clamp:3;-webkit-box-orient:vertical;max-width:100%;word-break:break-all;"], function (props) {
23
- return props.isExpanded ? 'wrap' : 'nowrap';
24
- }, function (props) {
25
- return props.isExpanded ? '-webkit-box' : 'inline-block';
26
- });
27
-
28
- var TruncatedExpandableText = function TruncatedExpandableText(_ref) {
29
- var containerProps = _ref.containerProps,
30
- value = _ref.value;
31
-
32
- var _useState = React.useState(false),
33
- _useState2 = _slicedToArray__default['default'](_useState, 2),
34
- open = _useState2[0],
35
- setOpen = _useState2[1];
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
36
25
 
37
- var ref = React.useRef(null);
38
- React.useLayoutEffect(function () {
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
+ const Text = /*#__PURE__*/styled__default["default"].span.withConfig({
28
+ componentId: "sc-1wjt65j-0"
29
+ })(["text-overflow:ellipsis;white-space:", ";overflow:hidden;display:", ";-webkit-line-clamp:3;-webkit-box-orient:vertical;max-width:100%;word-break:break-all;"], props => props.isExpanded ? 'wrap' : 'nowrap', props => props.isExpanded ? '-webkit-box' : 'inline-block');
30
+
31
+ const TruncatedExpandableText = _ref => {
32
+ let {
33
+ containerProps,
34
+ value
35
+ } = _ref;
36
+ const [open, setOpen] = react.useState(false);
37
+ const ref = react.useRef(null);
38
+ react.useLayoutEffect(() => {
39
39
  if (typeof value !== 'string') return;
40
40
  if (!open) return;
41
- var newHyphenizedValue = '';
42
- var element = ref.current;
41
+ let newHyphenizedValue = '';
42
+ const element = ref.current;
43
43
  element.innerText = newHyphenizedValue;
44
-
45
- var _element$getBoundingC = element.getBoundingClientRect(),
46
- previousHeight = _element$getBoundingC.height;
47
-
48
- value.split('').forEach(function (char, index) {
44
+ let {
45
+ height: previousHeight
46
+ } = element.getBoundingClientRect();
47
+ value.split('').forEach((char, index) => {
49
48
  // try the hyphen here
50
49
  element.innerText = "".concat(newHyphenizedValue, "-").concat(char);
51
-
52
- var _element$getBoundingC2 = element.getBoundingClientRect(),
53
- newHeight = _element$getBoundingC2.height; // if it's the first line or the height didn't change, hyphen doesn't go here,
50
+ const {
51
+ height: newHeight
52
+ } = element.getBoundingClientRect(); // if it's the first line or the height didn't change, hyphen doesn't go here,
54
53
  // since we tried "-c", we are sure that "c-" fits in the line (so we don't
55
54
  // ever have a case where the hyphen goes to the next line
56
55
 
57
-
58
56
  if (!index || previousHeight === newHeight) {
59
57
  newHyphenizedValue += char;
60
58
  } else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
61
59
  // end of word
62
60
  element.innerText = "".concat(newHyphenizedValue).concat(char); // sometimes the last character is wider and doesn't fit
63
61
 
64
- var _element$getBoundingC3 = element.getBoundingClientRect(),
65
- endOfWordHeight = _element$getBoundingC3.height;
66
-
62
+ const {
63
+ height: endOfWordHeight
64
+ } = element.getBoundingClientRect();
67
65
  if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += "-".concat(char);
68
66
  } else if (char.match(/\s/)) {
69
67
  // we dont want "- ", leave the space character only
@@ -79,25 +77,24 @@ var TruncatedExpandableText = function TruncatedExpandableText(_ref) {
79
77
  });
80
78
  element.innerText = newHyphenizedValue;
81
79
  }, [open, value]);
82
- return /*#__PURE__*/React__default['default'].createElement(Text, _extends__default['default']({
80
+ return /*#__PURE__*/jsxRuntime.jsx(Text, _objectSpread(_objectSpread({
83
81
  ref: ref
84
- }, containerProps, {
82
+ }, containerProps), {}, {
85
83
  isExpanded: open,
86
- onClick: function onClick(e) {
84
+ onClick: e => {
87
85
  e.persist();
88
86
  setOpen(!open);
89
87
  if (containerProps.onClick) containerProps.onClick(e);
90
88
  },
91
- "data-testid": "ds-truncated-expandable-text"
92
- }), value);
89
+ "data-testid": "ds-truncated-expandable-text",
90
+ children: value
91
+ }));
93
92
  };
94
93
 
95
- TruncatedExpandableText.propTypes = props.textProps;
96
94
  TruncatedExpandableText.defaultProps = defaultProps.defaultProps;
97
- var DSTruncatedExpandableTextWithSchema = reactDesc.describe(TruncatedExpandableText);
95
+ const DSTruncatedExpandableTextWithSchema = reactDesc.describe(TruncatedExpandableText);
98
96
  DSTruncatedExpandableTextWithSchema.propTypes = props.textProps;
99
97
 
100
98
  exports.DSTruncatedExpandableTextWithSchema = DSTruncatedExpandableTextWithSchema;
101
99
  exports.TruncatedExpandableText = TruncatedExpandableText;
102
- exports['default'] = TruncatedExpandableText;
103
- //# sourceMappingURL=TruncatedExpandableText.js.map
100
+ exports["default"] = TruncatedExpandableText;
@@ -2,10 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var defaultProps = {
5
+ const defaultProps = {
6
6
  containerProps: {},
7
7
  value: ''
8
8
  };
9
9
 
10
10
  exports.defaultProps = defaultProps;
11
- //# sourceMappingURL=defaultProps.js.map
package/cjs/index.js CHANGED
@@ -3,17 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var TruncatedExpandableText = require('./TruncatedExpandableText.js');
6
- require('@babel/runtime/helpers/extends');
7
- require('@babel/runtime/helpers/slicedToArray');
8
- require('react');
9
- require('react-desc');
10
- require('styled-components');
11
- require('./props.js');
12
- require('./defaultProps.js');
13
6
 
14
7
 
15
8
 
16
9
  exports.DSTruncatedExpandableTextWithSchema = TruncatedExpandableText.DSTruncatedExpandableTextWithSchema;
17
10
  exports.TruncatedExpandableText = TruncatedExpandableText.TruncatedExpandableText;
18
- exports.default = TruncatedExpandableText.TruncatedExpandableText;
19
- //# sourceMappingURL=index.js.map
11
+ exports["default"] = TruncatedExpandableText.TruncatedExpandableText;
package/cjs/props.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var reactDesc = require('react-desc');
6
6
 
7
- var textProps = {
7
+ const textProps = {
8
8
  /** props injected to wrapper of page header */
9
9
  containerProps: reactDesc.PropTypes.object.description('props injected to wrapper of truncated expandable text'),
10
10
 
@@ -13,4 +13,3 @@ var textProps = {
13
13
  };
14
14
 
15
15
  exports.textProps = textProps;
16
- //# sourceMappingURL=props.js.map
@@ -1,58 +1,58 @@
1
- import _extends from '@babel/runtime/helpers/esm/extends';
2
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
3
- import React, { useState, useRef, useLayoutEffect } from 'react';
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import 'core-js/modules/web.dom-collections.iterator.js';
3
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
4
+ import 'core-js/modules/esnext.iterator.constructor.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import 'core-js/modules/esnext.async-iterator.filter.js';
7
+ import 'core-js/modules/esnext.iterator.filter.js';
8
+ import { useState, useRef, useLayoutEffect } from 'react';
4
9
  import { describe } from 'react-desc';
5
10
  import styled from 'styled-components';
6
11
  import { textProps } from './props.js';
7
12
  import { defaultProps } from './defaultProps.js';
13
+ import { jsx } from 'react/jsx-runtime';
8
14
 
9
- var Text = /*#__PURE__*/styled.span.withConfig({
10
- componentId: "sc-1wjt65j-0"
11
- })(["text-overflow:ellipsis;white-space:", ";overflow:hidden;display:", ";-webkit-line-clamp:3;-webkit-box-orient:vertical;max-width:100%;word-break:break-all;"], function (props) {
12
- return props.isExpanded ? 'wrap' : 'nowrap';
13
- }, function (props) {
14
- return props.isExpanded ? '-webkit-box' : 'inline-block';
15
- });
16
-
17
- var TruncatedExpandableText = function TruncatedExpandableText(_ref) {
18
- var containerProps = _ref.containerProps,
19
- value = _ref.value;
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
20
16
 
21
- var _useState = useState(false),
22
- _useState2 = _slicedToArray(_useState, 2),
23
- open = _useState2[0],
24
- setOpen = _useState2[1];
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ const Text = /*#__PURE__*/styled.span.withConfig({
19
+ componentId: "sc-1wjt65j-0"
20
+ })(["text-overflow:ellipsis;white-space:", ";overflow:hidden;display:", ";-webkit-line-clamp:3;-webkit-box-orient:vertical;max-width:100%;word-break:break-all;"], props => props.isExpanded ? 'wrap' : 'nowrap', props => props.isExpanded ? '-webkit-box' : 'inline-block');
25
21
 
26
- var ref = useRef(null);
27
- useLayoutEffect(function () {
22
+ const TruncatedExpandableText = _ref => {
23
+ let {
24
+ containerProps,
25
+ value
26
+ } = _ref;
27
+ const [open, setOpen] = useState(false);
28
+ const ref = useRef(null);
29
+ useLayoutEffect(() => {
28
30
  if (typeof value !== 'string') return;
29
31
  if (!open) return;
30
- var newHyphenizedValue = '';
31
- var element = ref.current;
32
+ let newHyphenizedValue = '';
33
+ const element = ref.current;
32
34
  element.innerText = newHyphenizedValue;
33
-
34
- var _element$getBoundingC = element.getBoundingClientRect(),
35
- previousHeight = _element$getBoundingC.height;
36
-
37
- value.split('').forEach(function (char, index) {
35
+ let {
36
+ height: previousHeight
37
+ } = element.getBoundingClientRect();
38
+ value.split('').forEach((char, index) => {
38
39
  // try the hyphen here
39
40
  element.innerText = "".concat(newHyphenizedValue, "-").concat(char);
40
-
41
- var _element$getBoundingC2 = element.getBoundingClientRect(),
42
- newHeight = _element$getBoundingC2.height; // if it's the first line or the height didn't change, hyphen doesn't go here,
41
+ const {
42
+ height: newHeight
43
+ } = element.getBoundingClientRect(); // if it's the first line or the height didn't change, hyphen doesn't go here,
43
44
  // since we tried "-c", we are sure that "c-" fits in the line (so we don't
44
45
  // ever have a case where the hyphen goes to the next line
45
46
 
46
-
47
47
  if (!index || previousHeight === newHeight) {
48
48
  newHyphenizedValue += char;
49
49
  } else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
50
50
  // end of word
51
51
  element.innerText = "".concat(newHyphenizedValue).concat(char); // sometimes the last character is wider and doesn't fit
52
52
 
53
- var _element$getBoundingC3 = element.getBoundingClientRect(),
54
- endOfWordHeight = _element$getBoundingC3.height;
55
-
53
+ const {
54
+ height: endOfWordHeight
55
+ } = element.getBoundingClientRect();
56
56
  if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += "-".concat(char);
57
57
  } else if (char.match(/\s/)) {
58
58
  // we dont want "- ", leave the space character only
@@ -68,23 +68,22 @@ var TruncatedExpandableText = function TruncatedExpandableText(_ref) {
68
68
  });
69
69
  element.innerText = newHyphenizedValue;
70
70
  }, [open, value]);
71
- return /*#__PURE__*/React.createElement(Text, _extends({
71
+ return /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({
72
72
  ref: ref
73
- }, containerProps, {
73
+ }, containerProps), {}, {
74
74
  isExpanded: open,
75
- onClick: function onClick(e) {
75
+ onClick: e => {
76
76
  e.persist();
77
77
  setOpen(!open);
78
78
  if (containerProps.onClick) containerProps.onClick(e);
79
79
  },
80
- "data-testid": "ds-truncated-expandable-text"
81
- }), value);
80
+ "data-testid": "ds-truncated-expandable-text",
81
+ children: value
82
+ }));
82
83
  };
83
84
 
84
- TruncatedExpandableText.propTypes = textProps;
85
85
  TruncatedExpandableText.defaultProps = defaultProps;
86
- var DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);
86
+ const DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);
87
87
  DSTruncatedExpandableTextWithSchema.propTypes = textProps;
88
88
 
89
89
  export { DSTruncatedExpandableTextWithSchema, TruncatedExpandableText, TruncatedExpandableText as default };
90
- //# sourceMappingURL=TruncatedExpandableText.js.map
@@ -1,7 +1,6 @@
1
- var defaultProps = {
1
+ const defaultProps = {
2
2
  containerProps: {},
3
3
  value: ''
4
4
  };
5
5
 
6
6
  export { defaultProps };
7
- //# sourceMappingURL=defaultProps.js.map
package/esm/index.js CHANGED
@@ -1,9 +1 @@
1
1
  export { DSTruncatedExpandableTextWithSchema, TruncatedExpandableText, TruncatedExpandableText as default } from './TruncatedExpandableText.js';
2
- import '@babel/runtime/helpers/esm/extends';
3
- import '@babel/runtime/helpers/esm/slicedToArray';
4
- import 'react';
5
- import 'react-desc';
6
- import 'styled-components';
7
- import './props.js';
8
- import './defaultProps.js';
9
- //# sourceMappingURL=index.js.map
package/esm/props.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PropTypes } from 'react-desc';
2
2
 
3
- var textProps = {
3
+ const textProps = {
4
4
  /** props injected to wrapper of page header */
5
5
  containerProps: PropTypes.object.description('props injected to wrapper of truncated expandable text'),
6
6
 
@@ -9,4 +9,3 @@ var textProps = {
9
9
  };
10
10
 
11
11
  export { textProps };
12
- //# sourceMappingURL=props.js.map
package/package.json CHANGED
@@ -1,14 +1,42 @@
1
1
  {
2
2
  "name": "@elliemae/ds-truncated-expandable-text",
3
- "version": "1.60.0",
3
+ "version": "2.0.0-alpha.12",
4
4
  "license": "MIT",
5
- "description": "Ellie Mae - Dim Sum - Truncated Expandable Text",
6
- "module": "esm/index.js",
7
- "main": "cjs/index.js",
5
+ "description": "ICE MT - Dimsum - Truncated Expandable Text",
6
+ "module": "./esm/index.js",
7
+ "main": "./cjs/index.js",
8
+ "types": "./types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
13
+ },
14
+ "./TruncatedExpandableText": {
15
+ "import": "./esm/TruncatedExpandableText.js",
16
+ "require": "./cjs/TruncatedExpandableText.js"
17
+ },
18
+ "./props": {
19
+ "import": "./esm/props.js",
20
+ "require": "./cjs/props.js"
21
+ },
22
+ "./defaultProps": {
23
+ "import": "./esm/defaultProps.js",
24
+ "require": "./cjs/defaultProps.js"
25
+ }
26
+ },
8
27
  "sideEffects": [
9
28
  "*.css",
10
29
  "*.scss"
11
30
  ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://git.elliemae.io/platform-ui/dimsum.git"
34
+ },
35
+ "engines": {
36
+ "npm": ">=7",
37
+ "node": ">=14"
38
+ },
39
+ "author": "ICE MT",
12
40
  "scripts": {
13
41
  "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
14
42
  "prebuild": "exit 0",
@@ -16,20 +44,23 @@
16
44
  "build": "node ../../scripts/build/build.js"
17
45
  },
18
46
  "dependencies": {
19
- "react-desc": "^4.1.2"
47
+ "react-desc": "~4.1.3"
20
48
  },
21
49
  "devDependencies": {
22
- "@types/styled-components": "^5.1.9",
23
- "styled-components": "~5.3.0"
50
+ "@testing-library/react": "~12.1.2",
51
+ "@testing-library/user-event": "~13.5.0",
52
+ "@types/styled-components": "~5.1.15",
53
+ "styled-components": "~5.3.3"
24
54
  },
25
55
  "peerDependencies": {
26
- "lodash": "^4.17.20",
27
- "react": "^17.0.1",
28
- "react-dom": "^17.0.1",
29
- "styled-components": "^5.3.0"
56
+ "lodash": "^4.17.21",
57
+ "react": "^17.0.2",
58
+ "react-dom": "^17.0.2",
59
+ "styled-components": "^5.3.3"
30
60
  },
31
61
  "publishConfig": {
32
62
  "access": "public",
33
- "directory": "dist"
63
+ "directory": "dist",
64
+ "generateSubmodules": true
34
65
  }
35
66
  }
@@ -0,0 +1,36 @@
1
+ /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
+ import { HTMLAttributes } from 'react';
3
+ declare const TruncatedExpandableText: {
4
+ ({ containerProps, value, }: {
5
+ containerProps: HTMLAttributes<HTMLSpanElement>;
6
+ value: string;
7
+ }): JSX.Element;
8
+ propTypes: {
9
+ containerProps: {
10
+ defaultValue<T = unknown>(arg: T): {
11
+ deprecated: import("react-desc").PropTypesDescValidator;
12
+ };
13
+ isRequired: import("react-desc").PropTypesDescValidator;
14
+ };
15
+ value: {
16
+ defaultValue<T = unknown>(arg: T): {
17
+ deprecated: import("react-desc").PropTypesDescValidator;
18
+ };
19
+ isRequired: import("react-desc").PropTypesDescValidator;
20
+ };
21
+ };
22
+ defaultProps: {
23
+ containerProps: {};
24
+ value: string;
25
+ };
26
+ };
27
+ declare const DSTruncatedExpandableTextWithSchema: {
28
+ (props?: {
29
+ containerProps: HTMLAttributes<HTMLSpanElement>;
30
+ value: string;
31
+ } | undefined): JSX.Element;
32
+ propTypes: unknown;
33
+ toTypescript: () => import("react-desc").TypescriptSchema;
34
+ };
35
+ export { TruncatedExpandableText, DSTruncatedExpandableTextWithSchema };
36
+ export default TruncatedExpandableText;
@@ -0,0 +1,4 @@
1
+ export declare const defaultProps: {
2
+ containerProps: {};
3
+ value: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ export * from './TruncatedExpandableText';
2
+ export { default } from './TruncatedExpandableText';
@@ -0,0 +1,17 @@
1
+ /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
+ export declare const textProps: {
3
+ /** props injected to wrapper of page header */
4
+ containerProps: {
5
+ defaultValue<T = unknown>(arg: T): {
6
+ deprecated: import("react-desc").PropTypesDescValidator;
7
+ };
8
+ isRequired: import("react-desc").PropTypesDescValidator;
9
+ };
10
+ /** Text that when truncated will trigger the tooltip interaction */
11
+ value: {
12
+ defaultValue<T = unknown>(arg: T): {
13
+ deprecated: import("react-desc").PropTypesDescValidator;
14
+ };
15
+ isRequired: import("react-desc").PropTypesDescValidator;
16
+ };
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@elliemae/ds-truncated-expandable-text/TruncatedExpandableText",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ],
7
- "private": true,
8
- "main": "../cjs/TruncatedExpandableText.js",
9
- "module": "../esm/TruncatedExpandableText.js"
10
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"TruncatedExpandableText.js","sources":["../../src/TruncatedExpandableText.tsx"],"sourcesContent":["import React, {\n useRef,\n useState,\n useLayoutEffect,\n HTMLAttributes,\n} from 'react';\nimport { describe } from 'react-desc';\nimport styled from 'styled-components';\nimport { textProps } from './props';\nimport { defaultProps } from './defaultProps';\n\ntype TextProps = HTMLAttributes<HTMLSpanElement> & { isExpanded: boolean };\n\nconst Text = styled.span<TextProps>`\n text-overflow: ellipsis;\n white-space: ${(props) => (props.isExpanded ? 'wrap' : 'nowrap')};\n overflow: hidden;\n display: ${(props) => (props.isExpanded ? '-webkit-box' : 'inline-block')};\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n max-width: 100%;\n word-break: break-all;\n`;\n\nconst TruncatedExpandableText = ({\n containerProps,\n value,\n}: {\n containerProps: HTMLAttributes<HTMLSpanElement>;\n value: string;\n}): JSX.Element => {\n const [open, setOpen] = useState(false);\n const ref = useRef<HTMLSpanElement>(null);\n\n useLayoutEffect(() => {\n if (typeof value !== 'string') return;\n if (!open) return;\n\n let newHyphenizedValue = '';\n\n const element = ref.current;\n element.innerText = newHyphenizedValue;\n let { height: previousHeight } = element.getBoundingClientRect();\n\n value.split('').forEach((char, index) => {\n // try the hyphen here\n element.innerText = `${newHyphenizedValue}-${char}`;\n const { height: newHeight } = element.getBoundingClientRect();\n // if it's the first line or the height didn't change, hyphen doesn't go here,\n // since we tried \"-c\", we are sure that \"c-\" fits in the line (so we don't\n // ever have a case where the hyphen goes to the next line\n if (!index || previousHeight === newHeight) {\n newHyphenizedValue += char;\n } else if (index < value.length - 1 && value[index + 1].match(/\\s/)) {\n // end of word\n element.innerText = `${newHyphenizedValue}${char}`;\n\n // sometimes the last character is wider and doesn't fit\n const { height: endOfWordHeight } = element.getBoundingClientRect();\n if (endOfWordHeight === previousHeight) newHyphenizedValue += char;\n else newHyphenizedValue += `-${char}`;\n } else if (char.match(/\\s/)) {\n // we dont want \"- \", leave the space character only\n newHyphenizedValue += char;\n } else if (\n newHyphenizedValue.length &&\n newHyphenizedValue[newHyphenizedValue.length - 1].match(/\\s/)\n ) {\n // we produce and empty space to make sure to start on the next line\n newHyphenizedValue += ` ${char}`;\n } else {\n newHyphenizedValue += `-${char}`;\n }\n previousHeight = newHeight;\n });\n element.innerText = newHyphenizedValue;\n }, [open, value]);\n\n return (\n <Text\n ref={ref}\n {...containerProps}\n isExpanded={open}\n onClick={(e) => {\n e.persist();\n setOpen(!open);\n if (containerProps.onClick) containerProps.onClick(e);\n }}\n data-testid=\"ds-truncated-expandable-text\"\n >\n {value}\n </Text>\n );\n};\n\nTruncatedExpandableText.propTypes = textProps;\n\nTruncatedExpandableText.defaultProps = defaultProps;\n\nconst DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);\n\nDSTruncatedExpandableTextWithSchema.propTypes = textProps;\n\nexport { TruncatedExpandableText, DSTruncatedExpandableTextWithSchema };\nexport default TruncatedExpandableText;\n"],"names":["Text","styled","span","props","isExpanded","TruncatedExpandableText","containerProps","value","useState","open","setOpen","ref","useRef","useLayoutEffect","newHyphenizedValue","element","current","innerText","getBoundingClientRect","previousHeight","height","split","forEach","char","index","newHeight","length","match","endOfWordHeight","React","e","persist","onClick","propTypes","textProps","defaultProps","DSTruncatedExpandableTextWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,IAAMA,IAAI,gBAAGC,0BAAM,CAACC,IAAV;AAAA;AAAA,mKAEO,UAACC,KAAD;AAAA,SAAYA,KAAK,CAACC,UAAN,GAAmB,MAAnB,GAA4B,QAAxC;AAAA,CAFP,EAIG,UAACD,KAAD;AAAA,SAAYA,KAAK,CAACC,UAAN,GAAmB,aAAn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DC,eAAhD;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultProps.js","sources":["../../src/defaultProps.tsx"],"sourcesContent":["export const defaultProps = { containerProps: {}, value: '' };\n"],"names":["defaultProps","containerProps","value"],"mappings":";;;;IAAaA,YAAY,GAAG;AAAEC,EAAAA,cAAc,EAAE,EAAlB;AAAsBC,EAAAA,KAAK,EAAE;AAA7B;;;;"}
package/cjs/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
package/cjs/props.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.js","sources":["../../src/props.tsx"],"sourcesContent":["import { PropTypes } from 'react-desc';\n\nexport const textProps = {\n /** props injected to wrapper of page header */\n containerProps: PropTypes.object.description(\n 'props injected to wrapper of truncated expandable text',\n ),\n /** Text that when truncated will trigger the tooltip interaction */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Text that when truncated will trigger the tooltip interaction',\n ),\n};\n"],"names":["textProps","containerProps","PropTypes","object","description","value","oneOfType","string","number"],"mappings":";;;;;;IAEaA,SAAS,GAAG;AACvB;AACAC,EAAAA,cAAc,EAAEC,mBAAS,CAACC,MAAV,CAAiBC,WAAjB,CACd,wDADc,CAFO;;AAKvB;AACAC,EAAAA,KAAK,EAAEH,mBAAS,CAACI,SAAV,CAAoB,CAACJ,mBAAS,CAACK,MAAX,EAAmBL,mBAAS,CAACM,MAA7B,CAApB,EAA0DJ,WAA1D,CACL,+DADK;AANgB;;;;"}
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@elliemae/ds-truncated-expandable-text/defaultProps",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ],
7
- "private": true,
8
- "main": "../cjs/defaultProps.js",
9
- "module": "../esm/defaultProps.js"
10
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"TruncatedExpandableText.js","sources":["../../src/TruncatedExpandableText.tsx"],"sourcesContent":["import React, {\n useRef,\n useState,\n useLayoutEffect,\n HTMLAttributes,\n} from 'react';\nimport { describe } from 'react-desc';\nimport styled from 'styled-components';\nimport { textProps } from './props';\nimport { defaultProps } from './defaultProps';\n\ntype TextProps = HTMLAttributes<HTMLSpanElement> & { isExpanded: boolean };\n\nconst Text = styled.span<TextProps>`\n text-overflow: ellipsis;\n white-space: ${(props) => (props.isExpanded ? 'wrap' : 'nowrap')};\n overflow: hidden;\n display: ${(props) => (props.isExpanded ? '-webkit-box' : 'inline-block')};\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n max-width: 100%;\n word-break: break-all;\n`;\n\nconst TruncatedExpandableText = ({\n containerProps,\n value,\n}: {\n containerProps: HTMLAttributes<HTMLSpanElement>;\n value: string;\n}): JSX.Element => {\n const [open, setOpen] = useState(false);\n const ref = useRef<HTMLSpanElement>(null);\n\n useLayoutEffect(() => {\n if (typeof value !== 'string') return;\n if (!open) return;\n\n let newHyphenizedValue = '';\n\n const element = ref.current;\n element.innerText = newHyphenizedValue;\n let { height: previousHeight } = element.getBoundingClientRect();\n\n value.split('').forEach((char, index) => {\n // try the hyphen here\n element.innerText = `${newHyphenizedValue}-${char}`;\n const { height: newHeight } = element.getBoundingClientRect();\n // if it's the first line or the height didn't change, hyphen doesn't go here,\n // since we tried \"-c\", we are sure that \"c-\" fits in the line (so we don't\n // ever have a case where the hyphen goes to the next line\n if (!index || previousHeight === newHeight) {\n newHyphenizedValue += char;\n } else if (index < value.length - 1 && value[index + 1].match(/\\s/)) {\n // end of word\n element.innerText = `${newHyphenizedValue}${char}`;\n\n // sometimes the last character is wider and doesn't fit\n const { height: endOfWordHeight } = element.getBoundingClientRect();\n if (endOfWordHeight === previousHeight) newHyphenizedValue += char;\n else newHyphenizedValue += `-${char}`;\n } else if (char.match(/\\s/)) {\n // we dont want \"- \", leave the space character only\n newHyphenizedValue += char;\n } else if (\n newHyphenizedValue.length &&\n newHyphenizedValue[newHyphenizedValue.length - 1].match(/\\s/)\n ) {\n // we produce and empty space to make sure to start on the next line\n newHyphenizedValue += ` ${char}`;\n } else {\n newHyphenizedValue += `-${char}`;\n }\n previousHeight = newHeight;\n });\n element.innerText = newHyphenizedValue;\n }, [open, value]);\n\n return (\n <Text\n ref={ref}\n {...containerProps}\n isExpanded={open}\n onClick={(e) => {\n e.persist();\n setOpen(!open);\n if (containerProps.onClick) containerProps.onClick(e);\n }}\n data-testid=\"ds-truncated-expandable-text\"\n >\n {value}\n </Text>\n );\n};\n\nTruncatedExpandableText.propTypes = textProps;\n\nTruncatedExpandableText.defaultProps = defaultProps;\n\nconst DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);\n\nDSTruncatedExpandableTextWithSchema.propTypes = textProps;\n\nexport { TruncatedExpandableText, DSTruncatedExpandableTextWithSchema };\nexport default TruncatedExpandableText;\n"],"names":["Text","styled","span","props","isExpanded","TruncatedExpandableText","containerProps","value","useState","open","setOpen","ref","useRef","useLayoutEffect","newHyphenizedValue","element","current","innerText","getBoundingClientRect","previousHeight","height","split","forEach","char","index","newHeight","length","match","endOfWordHeight","e","persist","onClick","propTypes","textProps","defaultProps","DSTruncatedExpandableTextWithSchema","describe"],"mappings":";;;;;;;;AAaA,IAAMA,IAAI,gBAAGC,MAAM,CAACC,IAAV;AAAA;AAAA,mKAEO,UAACC,KAAD;AAAA,SAAYA,KAAK,CAACC,UAAN,GAAmB,MAAnB,GAA4B,QAAxC;AAAA,CAFP,EAIG,UAACD,KAAD;AAAA,SAAYA,KAAK,CAACC,UAAN,GAAmB,aAAnB,GAAmC,cAA/C;AAAA,CAJH,CAAV;;IAWMC,uBAAuB,GAAG,SAA1BA,uBAA0B,OAMb;AAAA,MALjBC,cAKiB,QALjBA,cAKiB;AAAA,MAJjBC,KAIiB,QAJjBA,KAIiB;;AACjB,kBAAwBC,QAAQ,CAAC,KAAD,CAAhC;AAAA;AAAA,MAAOC,IAAP;AAAA,MAAaC,OAAb;;AACA,MAAMC,GA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A,kBAAkB,IAAIS,IAAtB;AACD,OAHM,MAGA,IACLT,kBAAkB,CAACY,MAAnB,IACAZ,kBAAkB,CAACA,kBAAkB,CAACY,MAAnB,GAA4B,CAA7B,CAAlB,CAAkDC,KAAlD,CAAwD,IAAxD,CAFK,EAGL;AACA;AACAb,QAAAA,kBAAkB,eAAQS,IAAR,CAAlB;AACD,OANM,MAMA;AACLT,QAAAA,kBAAkB,eAAQS,IAAR,CAAlB;AACD;;AACDJ,MAAAA,cAAc,GAAGM,SAAjB;AACD,KA9BD;AA+BAV,IAAAA,OAAO,CAACE,SAAR,GAAoBH,kBAApB;AACD,GA1Cc,EA0CZ,CAACL,IAAD,EAAOF,KAAP,CA1CY,CAAf;AA4CA,sBACE,oBAAC,IAAD;AACE,IAAA,GAAG,EAAEI;AADP,KAEML,cAFN;AAGE,IAAA,UAAU,EAAEG,IAHd;AAIE,IAAA,OAAO,EAAE,iBAACoB,CAAD,EAAO;AACdA,MAAAA,CAAC,CAACC,OAAF;AACApB,MAAAA,OAAO,CAAC,CAACD,IAAF,CAAP;AACA,UAAIH,cAAc,CAACyB,OAAnB,EAA4BzB,cAAc,CAACyB,OAAf,CAAuBF,CAAvB;AAC7B,KARH;AASE,mBAAY;AATd,MAWGtB,KAXH,CADF;AAeD;;AAEDF,uBAAuB,CAAC2B,SAAxB,GAAoCC,SAApC;AAEA5B,uBAAuB,CAAC6B,YAAxB,GAAuCA,YAAvC;IAEMC,mCAAmC,GAAGC,QAAQ,CAAC/B,uBAAD;AAEpD8B,mCAAmC,CAACH,SAApC,GAAgDC,SAAhD;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultProps.js","sources":["../../src/defaultProps.tsx"],"sourcesContent":["export const defaultProps = { containerProps: {}, value: '' };\n"],"names":["defaultProps","containerProps","value"],"mappings":"IAAaA,YAAY,GAAG;AAAEC,EAAAA,cAAc,EAAE,EAAlB;AAAsBC,EAAAA,KAAK,EAAE;AAA7B;;;;"}
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
package/esm/props.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.js","sources":["../../src/props.tsx"],"sourcesContent":["import { PropTypes } from 'react-desc';\n\nexport const textProps = {\n /** props injected to wrapper of page header */\n containerProps: PropTypes.object.description(\n 'props injected to wrapper of truncated expandable text',\n ),\n /** Text that when truncated will trigger the tooltip interaction */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Text that when truncated will trigger the tooltip interaction',\n ),\n};\n"],"names":["textProps","containerProps","PropTypes","object","description","value","oneOfType","string","number"],"mappings":";;IAEaA,SAAS,GAAG;AACvB;AACAC,EAAAA,cAAc,EAAEC,SAAS,CAACC,MAAV,CAAiBC,WAAjB,CACd,wDADc,CAFO;;AAKvB;AACAC,EAAAA,KAAK,EAAEH,SAAS,CAACI,SAAV,CAAoB,CAACJ,SAAS,CAACK,MAAX,EAAmBL,SAAS,CAACM,MAA7B,CAApB,EAA0DJ,WAA1D,CACL,+DADK;AANgB;;;;"}
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@elliemae/ds-truncated-expandable-text/props",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ],
7
- "private": true,
8
- "main": "../cjs/props.js",
9
- "module": "../esm/props.js"
10
- }