@elliemae/ds-truncated-expandable-text 2.0.0-alpha.1 → 2.0.0-alpha.13

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.
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
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');
6
12
  var react = require('react');
7
13
  var reactDesc = require('react-desc');
8
14
  var styled = require('styled-components');
@@ -17,15 +23,16 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
17
23
 
18
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; }
19
25
 
20
- 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; }
21
- const Text = /*#__PURE__*/styled__default['default'].span.withConfig({
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({
22
28
  componentId: "sc-1wjt65j-0"
23
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');
24
30
 
25
- const TruncatedExpandableText = ({
26
- containerProps,
27
- value
28
- }) => {
31
+ const TruncatedExpandableText = _ref => {
32
+ let {
33
+ containerProps,
34
+ value
35
+ } = _ref;
29
36
  const [open, setOpen] = react.useState(false);
30
37
  const ref = react.useRef(null);
31
38
  react.useLayoutEffect(() => {
@@ -39,7 +46,7 @@ const TruncatedExpandableText = ({
39
46
  } = element.getBoundingClientRect();
40
47
  value.split('').forEach((char, index) => {
41
48
  // try the hyphen here
42
- element.innerText = `${newHyphenizedValue}-${char}`;
49
+ element.innerText = "".concat(newHyphenizedValue, "-").concat(char);
43
50
  const {
44
51
  height: newHeight
45
52
  } = element.getBoundingClientRect(); // if it's the first line or the height didn't change, hyphen doesn't go here,
@@ -50,20 +57,20 @@ const TruncatedExpandableText = ({
50
57
  newHyphenizedValue += char;
51
58
  } else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
52
59
  // end of word
53
- element.innerText = `${newHyphenizedValue}${char}`; // sometimes the last character is wider and doesn't fit
60
+ element.innerText = "".concat(newHyphenizedValue).concat(char); // sometimes the last character is wider and doesn't fit
54
61
 
55
62
  const {
56
63
  height: endOfWordHeight
57
64
  } = element.getBoundingClientRect();
58
- if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += `-${char}`;
65
+ if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += "-".concat(char);
59
66
  } else if (char.match(/\s/)) {
60
67
  // we dont want "- ", leave the space character only
61
68
  newHyphenizedValue += char;
62
69
  } else if (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\s/)) {
63
70
  // we produce and empty space to make sure to start on the next line
64
- newHyphenizedValue += ` ${char}`;
71
+ newHyphenizedValue += " ".concat(char);
65
72
  } else {
66
- newHyphenizedValue += `-${char}`;
73
+ newHyphenizedValue += "-".concat(char);
67
74
  }
68
75
 
69
76
  previousHeight = newHeight;
@@ -90,4 +97,4 @@ DSTruncatedExpandableTextWithSchema.propTypes = props.textProps;
90
97
 
91
98
  exports.DSTruncatedExpandableTextWithSchema = DSTruncatedExpandableTextWithSchema;
92
99
  exports.TruncatedExpandableText = TruncatedExpandableText;
93
- exports['default'] = TruncatedExpandableText;
100
+ exports["default"] = TruncatedExpandableText;
package/cjs/index.js CHANGED
@@ -8,4 +8,4 @@ var TruncatedExpandableText = require('./TruncatedExpandableText.js');
8
8
 
9
9
  exports.DSTruncatedExpandableTextWithSchema = TruncatedExpandableText.DSTruncatedExpandableTextWithSchema;
10
10
  exports.TruncatedExpandableText = TruncatedExpandableText.TruncatedExpandableText;
11
- exports.default = TruncatedExpandableText.TruncatedExpandableText;
11
+ exports["default"] = TruncatedExpandableText.TruncatedExpandableText;
@@ -1,4 +1,10 @@
1
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';
2
8
  import { useState, useRef, useLayoutEffect } from 'react';
3
9
  import { describe } from 'react-desc';
4
10
  import styled from 'styled-components';
@@ -13,10 +19,11 @@ const Text = /*#__PURE__*/styled.span.withConfig({
13
19
  componentId: "sc-1wjt65j-0"
14
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');
15
21
 
16
- const TruncatedExpandableText = ({
17
- containerProps,
18
- value
19
- }) => {
22
+ const TruncatedExpandableText = _ref => {
23
+ let {
24
+ containerProps,
25
+ value
26
+ } = _ref;
20
27
  const [open, setOpen] = useState(false);
21
28
  const ref = useRef(null);
22
29
  useLayoutEffect(() => {
@@ -30,7 +37,7 @@ const TruncatedExpandableText = ({
30
37
  } = element.getBoundingClientRect();
31
38
  value.split('').forEach((char, index) => {
32
39
  // try the hyphen here
33
- element.innerText = `${newHyphenizedValue}-${char}`;
40
+ element.innerText = "".concat(newHyphenizedValue, "-").concat(char);
34
41
  const {
35
42
  height: newHeight
36
43
  } = element.getBoundingClientRect(); // if it's the first line or the height didn't change, hyphen doesn't go here,
@@ -41,20 +48,20 @@ const TruncatedExpandableText = ({
41
48
  newHyphenizedValue += char;
42
49
  } else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
43
50
  // end of word
44
- element.innerText = `${newHyphenizedValue}${char}`; // sometimes the last character is wider and doesn't fit
51
+ element.innerText = "".concat(newHyphenizedValue).concat(char); // sometimes the last character is wider and doesn't fit
45
52
 
46
53
  const {
47
54
  height: endOfWordHeight
48
55
  } = element.getBoundingClientRect();
49
- if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += `-${char}`;
56
+ if (endOfWordHeight === previousHeight) newHyphenizedValue += char;else newHyphenizedValue += "-".concat(char);
50
57
  } else if (char.match(/\s/)) {
51
58
  // we dont want "- ", leave the space character only
52
59
  newHyphenizedValue += char;
53
60
  } else if (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\s/)) {
54
61
  // we produce and empty space to make sure to start on the next line
55
- newHyphenizedValue += ` ${char}`;
62
+ newHyphenizedValue += " ".concat(char);
56
63
  } else {
57
- newHyphenizedValue += `-${char}`;
64
+ newHyphenizedValue += "-".concat(char);
58
65
  }
59
66
 
60
67
  previousHeight = newHeight;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-truncated-expandable-text",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.13",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Truncated Expandable Text",
6
6
  "module": "./esm/index.js",
@@ -44,18 +44,19 @@
44
44
  "build": "node ../../scripts/build/build.js"
45
45
  },
46
46
  "dependencies": {
47
- "@elliemae/ds-classnames": "2.0.0-alpha.1",
48
- "@elliemae/ds-utilities": "2.0.0-alpha.1"
47
+ "react-desc": "~4.1.3"
49
48
  },
50
49
  "devDependencies": {
51
- "@types/styled-components": "~5.1.14",
52
- "styled-components": "~5.3.1"
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"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "lodash": "^4.17.21",
56
57
  "react": "^17.0.2",
57
58
  "react-dom": "^17.0.2",
58
- "styled-components": "^5.3.1"
59
+ "styled-components": "^5.3.3"
59
60
  },
60
61
  "publishConfig": {
61
62
  "access": "public",
@@ -1,3 +1,4 @@
1
+ /// <reference path="../../../../shared/typings/react-desc.d.ts" />
1
2
  import { HTMLAttributes } from 'react';
2
3
  declare const TruncatedExpandableText: {
3
4
  ({ containerProps, value, }: {
@@ -5,14 +6,31 @@ declare const TruncatedExpandableText: {
5
6
  value: string;
6
7
  }): JSX.Element;
7
8
  propTypes: {
8
- containerProps: any;
9
- value: any;
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
+ };
10
21
  };
11
22
  defaultProps: {
12
23
  containerProps: {};
13
24
  value: string;
14
25
  };
15
26
  };
16
- declare const DSTruncatedExpandableTextWithSchema: any;
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
+ };
17
35
  export { TruncatedExpandableText, DSTruncatedExpandableTextWithSchema };
18
36
  export default TruncatedExpandableText;
package/types/props.d.ts CHANGED
@@ -1,6 +1,17 @@
1
+ /// <reference path="../../../../shared/typings/react-desc.d.ts" />
1
2
  export declare const textProps: {
2
3
  /** props injected to wrapper of page header */
3
- containerProps: any;
4
+ containerProps: {
5
+ defaultValue<T = unknown>(arg: T): {
6
+ deprecated: import("react-desc").PropTypesDescValidator;
7
+ };
8
+ isRequired: import("react-desc").PropTypesDescValidator;
9
+ };
4
10
  /** Text that when truncated will trigger the tooltip interaction */
5
- value: any;
11
+ value: {
12
+ defaultValue<T = unknown>(arg: T): {
13
+ deprecated: import("react-desc").PropTypesDescValidator;
14
+ };
15
+ isRequired: import("react-desc").PropTypesDescValidator;
16
+ };
6
17
  };
package/cjs/package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ]
7
- }
package/esm/package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "type": "module",
3
- "sideEffects": [
4
- "*.css",
5
- "*.scss"
6
- ]
7
- }