@elliemae/ds-truncated-expandable-text 3.0.0-next.5 → 3.0.0-next.53

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.
@@ -21,33 +21,27 @@ var __spreadValues = (a, b) => {
21
21
  return a;
22
22
  };
23
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
24
  var __export = (target, all) => {
26
25
  for (var name in all)
27
26
  __defProp(target, name, { get: all[name], enumerable: true });
28
27
  };
29
- var __reExport = (target, module2, copyDefault, desc) => {
30
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
31
- for (let key of __getOwnPropNames(module2))
32
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
33
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
33
  }
35
- return target;
34
+ return to;
36
35
  };
37
- var __toESM = (module2, isNodeMode) => {
38
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
39
- };
40
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
41
- return (module2, temp) => {
42
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
43
- };
44
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
38
  var TruncatedExpandableText_exports = {};
46
39
  __export(TruncatedExpandableText_exports, {
47
40
  DSTruncatedExpandableTextWithSchema: () => DSTruncatedExpandableTextWithSchema,
48
41
  TruncatedExpandableText: () => TruncatedExpandableText,
49
42
  default: () => TruncatedExpandableText_default
50
43
  });
44
+ module.exports = __toCommonJS(TruncatedExpandableText_exports);
51
45
  var React = __toESM(require("react"));
52
46
  var import_react = __toESM(require("react"));
53
47
  var import_react_desc = require("react-desc");
@@ -120,5 +114,4 @@ TruncatedExpandableText.defaultProps = import_defaultProps.defaultProps;
120
114
  const DSTruncatedExpandableTextWithSchema = (0, import_react_desc.describe)(TruncatedExpandableText);
121
115
  DSTruncatedExpandableTextWithSchema.propTypes = import_props.textProps;
122
116
  var TruncatedExpandableText_default = TruncatedExpandableText;
123
- module.exports = __toCommonJS(TruncatedExpandableText_exports);
124
117
  //# sourceMappingURL=TruncatedExpandableText.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/TruncatedExpandableText.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
4
  "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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAKO;AACP,wBAAyB;AACzB,+BAAmB;AACnB,mBAA0B;AAC1B,0BAA6B;AAI7B,MAAM,OAAO,iCAAO;AAAA;AAAA,iBAEH,CAAC,UAAW,MAAM,aAAa,SAAS;AAAA;AAAA,aAE5C,CAAC,UAAW,MAAM,aAAa,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO5D,MAAM,0BAA0B,CAAC;AAAA,EAC/B;AAAA,EACA;AAAA,MAIiB;AACjB,QAAM,CAAC,MAAM,WAAW,2BAAS;AACjC,QAAM,MAAM,yBAAwB;AAEpC,oCAAgB,MAAM;AACpB,QAAI,OAAO,UAAU;AAAU;AAC/B,QAAI,CAAC;AAAM;AAEX,QAAI,qBAAqB;AAEzB,UAAM,UAAU,IAAI;AACpB,YAAQ,YAAY;AACpB,QAAI,EAAE,QAAQ,mBAAmB,QAAQ;AAEzC,UAAM,MAAM,IAAI,QAAQ,CAAC,MAAM,UAAU;AAEvC,cAAQ,YAAY,GAAG,sBAAsB;AAC7C,YAAM,EAAE,QAAQ,cAAc,QAAQ;AAItC,UAAI,CAAC,SAAS,mBAAmB,WAAW;AAC1C,8BAAsB;AAAA,iBACb,QAAQ,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAG,MAAM,OAAO;AAEnE,gBAAQ,YAAY,GAAG,qBAAqB;AAG5C,cAAM,EAAE,QAAQ,oBAAoB,QAAQ;AAC5C,YAAI,oBAAoB;AAAgB,gCAAsB;AAAA;AACzD,gCAAsB,IAAI;AAAA,iBACtB,KAAK,MAAM,OAAO;AAE3B,8BAAsB;AAAA,iBAEtB,mBAAmB,UACnB,mBAAmB,mBA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,sBAAsB;AAC7C,YAAM,EAAE,QAAQ,cAAc,QAAQ,sBAAsB;AAI5D,UAAI,CAAC,SAAS,mBAAmB,WAAW;AAC1C,8BAAsB;AAAA,MACxB,WAAW,QAAQ,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAG,MAAM,IAAI,GAAG;AAEnE,gBAAQ,YAAY,GAAG,qBAAqB;AAG5C,cAAM,EAAE,QAAQ,oBAAoB,QAAQ,sBAAsB;AAClE,YAAI,oBAAoB;AAAgB,gCAAsB;AAAA;AACzD,gCAAsB,IAAI;AAAA,MACjC,WAAW,KAAK,MAAM,IAAI,GAAG;AAE3B,8BAAsB;AAAA,MACxB,WACE,mBAAmB,UACnB,mBAAmB,mBAAmB,SAAS,GAAG,MAAM,IAAI,GAC5D;AAEA,8BAAsB,IAAI;AAAA,MAC5B,OAAO;AACL,8BAAsB,IAAI;AAAA,MAC5B;AACA,uBAAiB;AAAA,IACnB,CAAC;AACD,YAAQ,YAAY;AAAA,EACtB,GAAG,CAAC,MAAM,KAAK,CAAC;AAEhB,SACE,mDAAC;AAAA,IACC;AAAA,KACI,iBAFL;AAAA,IAGC,YAAY;AAAA,IACZ,SAAS,CAAC,MAAM;AACd,QAAE,QAAQ;AACV,cAAQ,CAAC,IAAI;AACb,UAAI,eAAe;AAAS,uBAAe,QAAQ,CAAC;AAAA,IACtD;AAAA,IACA,eAAY;AAAA,MAEX,KACH;AAEJ;AAEA,wBAAwB,YAAY;AAEpC,wBAAwB,eAAe;AAEvC,MAAM,sCAAsC,gCAAS,uBAAuB;AAE5E,oCAAoC,YAAY;AAGhD,IAAO,kCAAQ;",
6
6
  "names": []
7
7
  }
@@ -4,32 +4,25 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
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 });
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
16
  }
18
- return target;
17
+ return to;
19
18
  };
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);
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
21
  var defaultProps_exports = {};
29
22
  __export(defaultProps_exports, {
30
23
  defaultProps: () => defaultProps
31
24
  });
25
+ module.exports = __toCommonJS(defaultProps_exports);
32
26
  var React = __toESM(require("react"));
33
27
  const defaultProps = { containerProps: {}, value: "" };
34
- module.exports = __toCommonJS(defaultProps_exports);
35
28
  //# sourceMappingURL=defaultProps.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/defaultProps.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
4
  "sourcesContent": ["export const defaultProps = { containerProps: {}, value: '' };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,eAAe,EAAE,gBAAgB,IAAI,OAAO;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,eAAe,EAAE,gBAAgB,CAAC,GAAG,OAAO,GAAG;",
6
6
  "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -4,33 +4,27 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
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 });
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
16
  }
18
- return target;
17
+ return to;
19
18
  };
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);
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
22
  var src_exports = {};
29
23
  __export(src_exports, {
30
24
  default: () => import_TruncatedExpandableText.default
31
25
  });
26
+ module.exports = __toCommonJS(src_exports);
32
27
  var React = __toESM(require("react"));
33
- __reExport(src_exports, require("./TruncatedExpandableText"));
28
+ __reExport(src_exports, require("./TruncatedExpandableText"), module.exports);
34
29
  var import_TruncatedExpandableText = __toESM(require("./TruncatedExpandableText"));
35
- module.exports = __toCommonJS(src_exports);
36
30
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
4
  "sourcesContent": ["export * from './TruncatedExpandableText';\nexport { default } from './TruncatedExpandableText';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,qCAAwB;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc,sCAAd;AACA,qCAAwB;",
6
6
  "names": []
7
7
  }
package/dist/cjs/props.js CHANGED
@@ -4,36 +4,29 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
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 });
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
16
  }
18
- return target;
17
+ return to;
19
18
  };
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);
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
21
  var props_exports = {};
29
22
  __export(props_exports, {
30
23
  textProps: () => textProps
31
24
  });
25
+ module.exports = __toCommonJS(props_exports);
32
26
  var React = __toESM(require("react"));
33
27
  var import_react_desc = require("react-desc");
34
28
  const textProps = {
35
29
  containerProps: import_react_desc.PropTypes.object.description("props injected to wrapper of truncated expandable text"),
36
30
  value: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("Text that when truncated will trigger the tooltip interaction")
37
31
  };
38
- module.exports = __toCommonJS(props_exports);
39
32
  //# sourceMappingURL=props.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/props.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
4
  "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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EAEvB,gBAAgB,4BAAU,OAAO,YAC/B;AAAA,EAGF,OAAO,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,SAAS,YAC/D;AAAA;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EAEvB,gBAAgB,4BAAU,OAAO,YAC/B,wDACF;AAAA,EAEA,OAAO,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,MAAM,CAAC,EAAE,YAC/D,+DACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TruncatedExpandableText.tsx"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACA;AACA;AACA;AAIA,MAAM,OAAO,OAAO;AAAA;AAAA,iBAEH,CAAC,UAAW,MAAM,aAAa,SAAS;AAAA;AAAA,aAE5C,CAAC,UAAW,MAAM,aAAa,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO5D,MAAM,0BAA0B,CAAC;AAAA,EAC/B;AAAA,EACA;AAAA,MAIiB;AACjB,QAAM,CAAC,MAAM,WAAW,SAAS;AACjC,QAAM,MAAM,OAAwB;AAEpC,kBAAgB,MAAM;AACpB,Q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AGC,YAAY;AAAA,IACZ,SAAS,CAAC,MAAM;AACd,QAAE,QAAQ;AACV,cAAQ,CAAC,IAAI;AACb,UAAI,eAAe;AAAS,uBAAe,QAAQ,CAAC;AAAA,IACtD;AAAA,IACA,eAAY;AAAA,MAEX,KACH;AAEJ;AAEA,wBAAwB,YAAY;AAEpC,wBAAwB,eAAe;AAEvC,MAAM,sCAAsC,SAAS,uBAAuB;AAE5E,oCAAoC,YAAY;AAGhD,IAAO,kCAAQ;",
6
6
  "names": []
7
7
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/defaultProps.tsx"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const defaultProps = { containerProps: {}, value: '' };\n"],
5
- "mappings": "AAAA;ACAO,MAAM,eAAe,EAAE,gBAAgB,IAAI,OAAO;",
5
+ "mappings": "AAAA;ACAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,GAAG,OAAO,GAAG;",
6
6
  "names": []
7
7
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/props.tsx"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
- "mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EAEvB,gBAAgB,UAAU,OAAO,YAC/B;AAAA,EAGF,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAC/D;AAAA;",
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EAEvB,gBAAgB,UAAU,OAAO,YAC/B,wDACF;AAAA,EAEA,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,EAAE,YAC/D,+DACF;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-truncated-expandable-text",
3
- "version": "3.0.0-next.5",
3
+ "version": "3.0.0-next.53",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Truncated Expandable Text",
6
6
  "files": [
@@ -46,13 +46,20 @@
46
46
  "reportFile": "tests.xml",
47
47
  "indent": 4
48
48
  },
49
+ "scripts": {
50
+ "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
51
+ "test": "node ../../scripts/testing/test.mjs",
52
+ "lint": "node ../../scripts/lint.mjs",
53
+ "dts": "node ../../scripts/dts.mjs",
54
+ "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
55
+ },
49
56
  "dependencies": {
50
57
  "react-desc": "~4.1.3"
51
58
  },
52
59
  "devDependencies": {
53
60
  "@testing-library/react": "~12.1.2",
54
61
  "@testing-library/user-event": "~13.5.0",
55
- "@types/styled-components": "~5.1.19",
62
+ "@types/styled-components": "~5.1.22",
56
63
  "styled-components": "~5.3.3"
57
64
  },
58
65
  "peerDependencies": {
@@ -64,12 +71,5 @@
64
71
  "publishConfig": {
65
72
  "access": "public",
66
73
  "typeSafety": false
67
- },
68
- "scripts": {
69
- "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
70
- "test": "node ../../scripts/testing/test.mjs",
71
- "lint": "node ../../scripts/lint.mjs",
72
- "dts": "node ../../scripts/dts.mjs",
73
- "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
74
74
  }
75
- }
75
+ }