@elliemae/ds-truncated-expandable-text 3.35.0 → 3.36.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,10 +57,8 @@ const TruncatedExpandableText = ({
57
57
  const [open, setOpen] = (0, import_react.useState)(false);
58
58
  const ref = (0, import_react.useRef)(null);
59
59
  (0, import_react.useLayoutEffect)(() => {
60
- if (typeof value !== "string")
61
- return;
62
- if (!open)
63
- return;
60
+ if (typeof value !== "string") return;
61
+ if (!open) return;
64
62
  let newHyphenizedValue = "";
65
63
  const element = ref.current;
66
64
  element.innerText = newHyphenizedValue;
@@ -73,10 +71,8 @@ const TruncatedExpandableText = ({
73
71
  } else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
74
72
  element.innerText = `${newHyphenizedValue}${char}`;
75
73
  const { height: endOfWordHeight } = element.getBoundingClientRect();
76
- if (endOfWordHeight === previousHeight)
77
- newHyphenizedValue += char;
78
- else
79
- newHyphenizedValue += `-${char}`;
74
+ if (endOfWordHeight === previousHeight) newHyphenizedValue += char;
75
+ else newHyphenizedValue += `-${char}`;
80
76
  } else if (char.match(/\s/)) {
81
77
  newHyphenizedValue += char;
82
78
  } else if (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\s/)) {
@@ -97,15 +93,13 @@ const TruncatedExpandableText = ({
97
93
  onClick: (e) => {
98
94
  e.persist();
99
95
  setOpen(!open);
100
- if (containerProps.onClick)
101
- containerProps.onClick(e);
96
+ if (containerProps.onClick) containerProps.onClick(e);
102
97
  },
103
98
  "data-testid": "ds-truncated-expandable-text",
104
99
  children: value
105
100
  }
106
101
  );
107
102
  };
108
- TruncatedExpandableText.propTypes = import_props.textProps;
109
103
  TruncatedExpandableText.defaultProps = import_defaultProps.defaultProps;
110
104
  TruncatedExpandableText.displayName = "TruncatedExpandableText";
111
105
  const DSTruncatedExpandableTextWithSchema = (0, import_ds_props_helpers.describe)(TruncatedExpandableText);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/TruncatedExpandableText.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type { HTMLAttributes } from 'react';\nimport React, { useRef, useState, useLayoutEffect } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { textProps } from './props.js';\nimport { defaultProps } from './defaultProps.js';\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 (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\\s/)) {\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 innerRef={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;\nTruncatedExpandableText.displayName = 'TruncatedExpandableText';\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;AAAA;ACAA,YAAuB;ADwEnB;AAvEJ,mBAAyD;AACzD,8BAAyB;AACzB,uBAAuB;AACvB,mBAA0B;AAC1B,0BAA6B;AAI7B,MAAM,OAAO,wBAAO;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;AACF,MAGmB;AACjB,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,UAAM,qBAAwB,IAAI;AAExC,oCAAgB,MAAM;AACpB,QA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B,cAAc;AACtC,MAAM,0CAAsC,kCAAS,uBAAuB;AAE5E,oCAAoC,YAAY;AAGhD,IAAO,kCAAQ;",
4
+ "sourcesContent": ["import type { HTMLAttributes } from 'react';\nimport React, { useRef, useState, useLayoutEffect } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { textProps } from './props.js';\nimport { defaultProps } from './defaultProps.js';\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 (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\\s/)) {\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 innerRef={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.defaultProps = defaultProps;\nTruncatedExpandableText.displayName = 'TruncatedExpandableText';\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;AAAA;ACAA,YAAuB;ADwEnB;AAvEJ,mBAAyD;AACzD,8BAAyB;AACzB,uBAAuB;AACvB,mBAA0B;AAC1B,0BAA6B;AAI7B,MAAM,OAAO,wBAAO;AAAA;AAAA,iBAEH,CAAC,UAAW,MAAM,aAAa,SAAS,QAAS;AAAA;AAAA,aAErD,CAAC,UAAW,MAAM,aAAa,gBAAgB,cAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3E,MAAM,0BAA0B,CAAC;AAAA,EAC/B;AAAA,EACA;AACF,MAGmB;AACjB,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,UAAM,qBAAwB,IAAI;AAExC,oCAAgB,MAAM;AACpB,QAAI,OAAO,UAAU,SAAU;AAC/B,QAAI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AM,0CAAsC,kCAAS,uBAAuB;AAE5E,oCAAoC,YAAY;AAGhD,IAAO,kCAAQ;",
6
6
  "names": []
7
7
  }
@@ -22,10 +22,8 @@ const TruncatedExpandableText = ({
22
22
  const [open, setOpen] = useState(false);
23
23
  const ref = useRef(null);
24
24
  useLayoutEffect(() => {
25
- if (typeof value !== "string")
26
- return;
27
- if (!open)
28
- return;
25
+ if (typeof value !== "string") return;
26
+ if (!open) return;
29
27
  let newHyphenizedValue = "";
30
28
  const element = ref.current;
31
29
  element.innerText = newHyphenizedValue;
@@ -38,10 +36,8 @@ const TruncatedExpandableText = ({
38
36
  } else if (index < value.length - 1 && value[index + 1].match(/\s/)) {
39
37
  element.innerText = `${newHyphenizedValue}${char}`;
40
38
  const { height: endOfWordHeight } = element.getBoundingClientRect();
41
- if (endOfWordHeight === previousHeight)
42
- newHyphenizedValue += char;
43
- else
44
- newHyphenizedValue += `-${char}`;
39
+ if (endOfWordHeight === previousHeight) newHyphenizedValue += char;
40
+ else newHyphenizedValue += `-${char}`;
45
41
  } else if (char.match(/\s/)) {
46
42
  newHyphenizedValue += char;
47
43
  } else if (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\s/)) {
@@ -62,15 +58,13 @@ const TruncatedExpandableText = ({
62
58
  onClick: (e) => {
63
59
  e.persist();
64
60
  setOpen(!open);
65
- if (containerProps.onClick)
66
- containerProps.onClick(e);
61
+ if (containerProps.onClick) containerProps.onClick(e);
67
62
  },
68
63
  "data-testid": "ds-truncated-expandable-text",
69
64
  children: value
70
65
  }
71
66
  );
72
67
  };
73
- TruncatedExpandableText.propTypes = textProps;
74
68
  TruncatedExpandableText.defaultProps = defaultProps;
75
69
  TruncatedExpandableText.displayName = "TruncatedExpandableText";
76
70
  const DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/TruncatedExpandableText.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { HTMLAttributes } from 'react';\nimport React, { useRef, useState, useLayoutEffect } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { textProps } from './props.js';\nimport { defaultProps } from './defaultProps.js';\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 (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\\s/)) {\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 innerRef={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;\nTruncatedExpandableText.displayName = 'TruncatedExpandableText';\nconst DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);\n\nDSTruncatedExpandableTextWithSchema.propTypes = textProps;\n\nexport { TruncatedExpandableText, DSTruncatedExpandableTextWithSchema };\nexport default TruncatedExpandableText;\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACwEnB;AAvEJ,SAAgB,QAAQ,UAAU,uBAAuB;AACzD,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAI7B,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;AACF,MAGmB;AACjB,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,MAAM,OAAwB,IAAI;AAExC,kBAAgB,MAAM;AACpB,QAAI,OAAO,UAAU;AAAU;AAC/B,QAAI,CAAC;AAAM;AAEX,QAAI,qBAAqB;AAEzB,UAAM,UAAU,IAAI;AACpB,YAAQ,YAAY;AACpB,QAAI,EAA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", "import type { HTMLAttributes } from 'react';\nimport React, { useRef, useState, useLayoutEffect } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { textProps } from './props.js';\nimport { defaultProps } from './defaultProps.js';\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 (newHyphenizedValue.length && newHyphenizedValue[newHyphenizedValue.length - 1].match(/\\s/)) {\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 innerRef={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.defaultProps = defaultProps;\nTruncatedExpandableText.displayName = 'TruncatedExpandableText';\nconst DSTruncatedExpandableTextWithSchema = describe(TruncatedExpandableText);\n\nDSTruncatedExpandableTextWithSchema.propTypes = textProps;\n\nexport { TruncatedExpandableText, DSTruncatedExpandableTextWithSchema };\nexport default TruncatedExpandableText;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACwEnB;AAvEJ,SAAgB,QAAQ,UAAU,uBAAuB;AACzD,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAI7B,MAAM,OAAO,OAAO;AAAA;AAAA,iBAEH,CAAC,UAAW,MAAM,aAAa,SAAS,QAAS;AAAA;AAAA,aAErD,CAAC,UAAW,MAAM,aAAa,gBAAgB,cAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3E,MAAM,0BAA0B,CAAC;AAAA,EAC/B;AAAA,EACA;AACF,MAGmB;AACjB,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,MAAM,OAAwB,IAAI;AAExC,kBAAgB,MAAM;AACpB,QAAI,OAAO,UAAU,SAAU;AAC/B,QAAI,CAAC,KAAM;AAEX,QAAI,qBAAqB;AAEzB,UAAM,UAAU,IAAI;AACpB,YAAQ,YAAY;AACpB,QAAI,EAAE,QAAQ,eAAe,IAAI,QAAQ,sBAAsB;AAE/D,UAAM,MAAM,EAAE,EAAE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anElement>;
5
5
  value: string;
6
6
  }): JSX.Element;
7
- propTypes: {
8
- containerProps: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
9
- value: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
10
- };
11
7
  defaultProps: {
12
8
  containerProps: {};
13
9
  value: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-truncated-expandable-text",
3
- "version": "3.35.0",
3
+ "version": "3.36.0-next.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Truncated Expandable Text",
6
6
  "files": [
@@ -36,12 +36,12 @@
36
36
  "indent": 4
37
37
  },
38
38
  "dependencies": {
39
- "@elliemae/ds-props-helpers": "3.35.0",
40
- "@elliemae/ds-system": "3.35.0"
39
+ "@elliemae/ds-props-helpers": "3.36.0-next.1",
40
+ "@elliemae/ds-system": "3.36.0-next.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@elliemae/pui-cli": "~9.0.0-next.31",
44
- "@elliemae/ds-monorepo-devops": "3.35.0"
44
+ "@elliemae/ds-monorepo-devops": "3.36.0-next.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "lodash": "^4.17.21",