@elliemae/ds-read-more 3.12.0-rc.2 → 3.12.0-rc.3
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.
- package/dist/cjs/DSReadMore.js +43 -47
- package/dist/cjs/DSReadMore.js.map +2 -2
- package/dist/cjs/MoreLessButton.js +8 -7
- package/dist/cjs/MoreLessButton.js.map +1 -1
- package/dist/esm/DSReadMore.js +45 -49
- package/dist/esm/DSReadMore.js.map +2 -2
- package/dist/esm/MoreLessButton.js +8 -7
- package/dist/esm/MoreLessButton.js.map +1 -1
- package/package.json +6 -6
package/dist/cjs/DSReadMore.js
CHANGED
|
@@ -49,6 +49,24 @@ const Text = import_ds_system.styled.span`
|
|
|
49
49
|
hyphens: auto;
|
|
50
50
|
word-break: break-all;
|
|
51
51
|
`;
|
|
52
|
+
const overflows = ({ offsetHeight, scrollHeight }) => offsetHeight + 2 < scrollHeight;
|
|
53
|
+
const binSearchTextOverflow = (element, parent, content) => {
|
|
54
|
+
const text = element.innerText;
|
|
55
|
+
let left = 1;
|
|
56
|
+
let right = text.length;
|
|
57
|
+
let textEnd = 0;
|
|
58
|
+
while (left <= right) {
|
|
59
|
+
const middle = (left + right) / 2;
|
|
60
|
+
element.innerText = content.slice(0, middle);
|
|
61
|
+
if (overflows(parent))
|
|
62
|
+
right = middle - 1;
|
|
63
|
+
else {
|
|
64
|
+
left = middle + 1;
|
|
65
|
+
textEnd = middle;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
element.innerText = content.slice(0, textEnd);
|
|
69
|
+
};
|
|
52
70
|
const DSReadMore = (props) => {
|
|
53
71
|
const {
|
|
54
72
|
lines = 2,
|
|
@@ -60,41 +78,22 @@ const DSReadMore = (props) => {
|
|
|
60
78
|
ellipsis = "...",
|
|
61
79
|
withTooltip = false
|
|
62
80
|
} = props;
|
|
63
|
-
const
|
|
81
|
+
const textRef = (0, import_react.useRef)(null);
|
|
82
|
+
const textWrapperRef = (0, import_react.useRef)(null);
|
|
64
83
|
const [showButton, setShowButton] = (0, import_react.useState)(false);
|
|
65
84
|
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
66
|
-
const
|
|
67
|
-
const binSearchTextOverflow = (0, import_react.useCallback)(
|
|
68
|
-
(element, parent) => {
|
|
69
|
-
const text = element.innerText;
|
|
70
|
-
let left = 1;
|
|
71
|
-
let right = text.length;
|
|
72
|
-
let textEnd = 0;
|
|
73
|
-
while (left <= right) {
|
|
74
|
-
const middle = (left + right) / 2;
|
|
75
|
-
element.innerText = content.slice(0, middle);
|
|
76
|
-
if (overflows(parent))
|
|
77
|
-
right = middle - 1;
|
|
78
|
-
else {
|
|
79
|
-
left = middle + 1;
|
|
80
|
-
textEnd = middle;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
element.innerText = content.slice(0, textEnd);
|
|
84
|
-
},
|
|
85
|
-
[content]
|
|
86
|
-
);
|
|
85
|
+
const { width, height } = (0, import_ds_utilities.useOnElementResize)(textWrapperRef);
|
|
87
86
|
(0, import_react.useLayoutEffect)(() => {
|
|
88
|
-
const textElement =
|
|
89
|
-
const parentElement =
|
|
87
|
+
const textElement = textRef.current;
|
|
88
|
+
const parentElement = textWrapperRef.current;
|
|
90
89
|
if (parentElement && textElement) {
|
|
91
90
|
textElement.innerText = content;
|
|
92
91
|
setShowButton(expanded || overflows(parentElement));
|
|
93
92
|
if (!expanded && overflows(parentElement)) {
|
|
94
|
-
binSearchTextOverflow(textElement, parentElement);
|
|
93
|
+
binSearchTextOverflow(textElement, parentElement, content);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
|
-
}, [lines, content,
|
|
96
|
+
}, [lines, content, expanded, showButton, withTooltip, more, less, width, height]);
|
|
98
97
|
const toggleExpanded = (newExpanded) => {
|
|
99
98
|
setExpanded(newExpanded);
|
|
100
99
|
if (newExpanded)
|
|
@@ -102,42 +101,39 @@ const DSReadMore = (props) => {
|
|
|
102
101
|
else
|
|
103
102
|
onLess();
|
|
104
103
|
};
|
|
105
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
ref,
|
|
111
|
-
"data-testid": "ds-read_more-text",
|
|
112
|
-
"aria-label": content,
|
|
113
|
-
children: content
|
|
114
|
-
}),
|
|
115
|
-
showButton && !withTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MoreLessButton.MoreLessButton, {
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { ref: textWrapperRef, lines, expanded, children: [
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref: textRef, "data-testid": "ds-read_more-text", "aria-label": content, children: content }),
|
|
106
|
+
showButton && !withTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
+
import_MoreLessButton.MoreLessButton,
|
|
108
|
+
{
|
|
116
109
|
expanded,
|
|
117
110
|
label: expanded ? less : more,
|
|
118
111
|
onClick: () => toggleExpanded(!expanded),
|
|
119
112
|
ariaLabel: expanded ? less : more,
|
|
120
113
|
ellipsis,
|
|
121
114
|
dataTestId: "ds-read_more-button"
|
|
122
|
-
}
|
|
123
|
-
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
withTooltip && showButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
124
120
|
style: {
|
|
125
121
|
display: "inline-block"
|
|
126
122
|
},
|
|
127
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, {
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, { text: content, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
124
|
+
import_MoreLessButton.MoreLessButton,
|
|
125
|
+
{
|
|
130
126
|
expanded,
|
|
131
127
|
label: "...",
|
|
132
128
|
ariaLabel: content,
|
|
133
129
|
ellipsis,
|
|
134
130
|
withTooltip,
|
|
135
131
|
dataTestId: "ds-read_more-tooltip-button"
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
});
|
|
132
|
+
}
|
|
133
|
+
) })
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] });
|
|
141
137
|
};
|
|
142
138
|
const DSReadMoreProps = {
|
|
143
139
|
lines: import_ds_utilities.PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSReadMore.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { noop } from 'lodash';\nimport type { WeakValidationMap } from 'react';\nimport { describe, PropTypes, useOnElementResize } from '@elliemae/ds-utilities';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\n\nimport { buttonTypes } from '@elliemae/ds-button';\nimport { dsBasicSizes } from '@elliemae/ds-shared';\nimport { MoreLessButton } from './MoreLessButton';\nimport type { DSReadMoreT } from './index.d';\n\nconst Text = styled.span<{ lines: number; expanded: boolean }>`\n display: -webkit-box;\n -webkit-line-clamp: ${({ lines, expanded }) => (expanded ? 'unset' : lines)};\n -webkit-box-orient: vertical;\n -webkit-hyphens: auto;\n -moz-hyphens: auto;\n -ms-hyphens: auto;\n hyphens: auto;\n word-break: break-all;\n`;\n\n// offsetHeight + 2 takes into consideration any size of the button\nconst overflows = ({ offsetHeight, scrollHeight }: { offsetHeight: number; scrollHeight: number }) =>\n offsetHeight + 2 < scrollHeight;\n\n// Searchs the optimum cut on the text to have the button in the same line\nconst binSearchTextOverflow = (element: HTMLElement, parent: HTMLElement, content: string) => {\n const text = element.innerText;\n let left = 1;\n let right = text.length;\n let textEnd = 0;\n while (left <= right) {\n const middle = (left + right) / 2;\n element.innerText = content.slice(0, middle);\n if (overflows(parent)) right = middle - 1;\n else {\n left = middle + 1;\n textEnd = middle;\n }\n }\n element.innerText = content.slice(0, textEnd);\n};\n\nconst DSReadMore = (props: DSReadMoreT) => {\n const {\n lines = 2,\n more = 'more',\n less = 'less',\n onMore = noop,\n onLess = noop,\n content,\n ellipsis = '...',\n withTooltip = false,\n } = props;\n const textRef = useRef<HTMLSpanElement>(null);\n const textWrapperRef = useRef<HTMLSpanElement>(null);\n const [showButton, setShowButton] = useState(false);\n const [expanded, setExpanded] = useState(false);\n\n // We need to re-run the effect when the size of the container changes\n const { width, height } = useOnElementResize(textWrapperRef);\n\n useLayoutEffect(() => {\n const textElement = textRef.current;\n const parentElement = textWrapperRef.current;\n if (parentElement && textElement) {\n textElement.innerText = content;\n setShowButton(expanded || overflows(parentElement));\n if (!expanded && overflows(parentElement)) {\n binSearchTextOverflow(textElement, parentElement, content);\n }\n }\n }, [lines, content, expanded, showButton, withTooltip, more, less, width, height]);\n\n const toggleExpanded = (newExpanded: boolean) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n };\n\n return (\n <Text ref={textWrapperRef} lines={lines} expanded={expanded}>\n <span ref={textRef} data-testid=\"ds-read_more-text\" aria-label={content}>\n {content}\n </span>\n {showButton && !withTooltip && (\n <MoreLessButton\n expanded={expanded}\n label={expanded ? less : more}\n onClick={() => toggleExpanded(!expanded)}\n ariaLabel={expanded ? less : more}\n ellipsis={ellipsis}\n dataTestId=\"ds-read_more-button\"\n />\n )}\n {withTooltip && showButton && (\n <div\n style={{\n display: 'inline-block',\n }}\n >\n <DSTooltipV3 text={content}>\n <MoreLessButton\n expanded={expanded}\n label=\"...\"\n ariaLabel={content}\n ellipsis={ellipsis}\n withTooltip={withTooltip}\n dataTestId=\"ds-read_more-tooltip-button\"\n />\n </DSTooltipV3>\n </div>\n )}\n </Text>\n );\n};\n\nconst DSReadMoreProps = {\n /** Ammount of lines after you want to display an ellipsis + more/less button */\n lines: PropTypes.number\n .description('Ammount of lines after you want to display an ellipsis + more/less button')\n .defaultValue(2),\n /** Label which will appear on the 'More' button */\n more: PropTypes.string.description(\"Label which will appear on the 'More' button\").defaultValue('more'),\n /** Label which will appear on the 'Less' button */\n less: PropTypes.string.description(\"Label which will appear on the 'Less' button\").defaultValue('less'),\n /** Function which will execute when the user click the 'More' button */\n onMore: PropTypes.func.description(\"Function which will execute when the user click the 'More' button\"),\n /** Function which will execute when the user click the 'Less' button */\n onLess: PropTypes.func.description(\"Function which will execute when the user click the 'Less' button\"),\n /** The text content you want displayed */\n content: PropTypes.string.description('The text content you want displayed').isRequired,\n\n /** 'The type of button for more/less button' */\n buttonType: PropTypes.oneOf(buttonTypes).description('The type for the more/less button').defaultValue('link'),\n /**\n * ['s', 'm', 'l']\n */\n size: PropTypes.oneOf(dsBasicSizes as string[])\n .description('Size of the button')\n .defaultValue('s'),\n\n /** The text you want to appear when truncating */\n ellipsis: PropTypes.string.description('The text you want to appear when truncating').defaultValue('...'),\n withTooltip: PropTypes.bool\n .description('Whether to show expandable tooltip on ellipsis focus instead of expandable buttons')\n .defaultValue('false'),\n} as WeakValidationMap<unknown>;\n\nDSReadMore.propTypes = DSReadMoreProps;\n\nconst DSReadMoreWithSchema = describe(DSReadMore);\n\nDSReadMoreWithSchema.propTypes = DSReadMoreProps;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAA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Q,8BAAU,KAAK,YAAY,mEAAmE;AAAA,EAEtG,QAAQ,8BAAU,KAAK,YAAY,mEAAmE;AAAA,EAEtG,SAAS,8BAAU,OAAO,YAAY,qCAAqC,EAAE;AAAA,EAG7E,YAAY,8BAAU,MAAM,4BAAW,EAAE,YAAY,mCAAmC,EAAE,aAAa,MAAM;AAAA,EAI7G,MAAM,8BAAU,MAAM,6BAAwB,EAC3C,YAAY,oBAAoB,EAChC,aAAa,GAAG;AAAA,EAGnB,UAAU,8BAAU,OAAO,YAAY,6CAA6C,EAAE,aAAa,KAAK;AAAA,EACxG,aAAa,8BAAU,KACpB,YAAY,oFAAoF,EAChG,aAAa,OAAO;AACzB;AAEA,WAAW,YAAY;AAEvB,MAAM,2BAAuB,8BAAS,UAAU;AAEhD,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -49,10 +49,11 @@ const StyledButton = (0, import_ds_system.styled)(import_ds_button.DSButtonV2)`
|
|
|
49
49
|
`;
|
|
50
50
|
const MoreLessButton = (props) => {
|
|
51
51
|
const { expanded, ariaLabel, label, onClick, ellipsis, withTooltip, dataTestId } = props;
|
|
52
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
53
|
+
expanded || withTooltip ? " " : ellipsis,
|
|
54
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
StyledButton,
|
|
56
|
+
{
|
|
56
57
|
withTooltip,
|
|
57
58
|
"aria-label": ariaLabel,
|
|
58
59
|
buttonType: "text",
|
|
@@ -61,8 +62,8 @@ const MoreLessButton = (props) => {
|
|
|
61
62
|
size: "s",
|
|
62
63
|
"data-testid": dataTestId,
|
|
63
64
|
children: label
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
});
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] });
|
|
67
68
|
};
|
|
68
69
|
//# sourceMappingURL=MoreLessButton.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/MoreLessButton.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSButtonV2 } from '@elliemae/ds-button';\n\nimport type { MoreLessButtonT } from './index.d';\n\nconst StyledButton = styled(DSButtonV2)<{ withTooltip: boolean }>`\n padding: 0;\n color: ${({ withTooltip, theme }) => (withTooltip ? 'inherit' : `${theme.colors.brand['600']}`)};\n border: 0;\n margin: 0;\n font-size: 12px;\n font-weight: 200;\n min-width: 0px;\n height: auto;\n text-transform: unset;\n &:hover:not([disabled]) {\n color: ${({ withTooltip, theme }) => (withTooltip ? 'inherit' : `${theme.colors.brand['600']}`)};\n background-color: transparent;\n text-decoration: ${({ withTooltip }) => (withTooltip ? '' : 'underline')};\n }\n`;\nconst MoreLessButton = (props: MoreLessButtonT) => {\n const { expanded, ariaLabel, label, onClick, ellipsis, withTooltip, dataTestId } = props;\n\n return (\n <span>\n {expanded || withTooltip ? ' ' : ellipsis}\n\n <StyledButton\n withTooltip={withTooltip}\n aria-label={ariaLabel}\n buttonType=\"text\"\n onClick={onClick}\n aria-hidden\n size=\"s\"\n data-testid={dataTestId}\n >\n {label}\n </StyledButton>\n </span>\n );\n};\n\nexport { MoreLessButton };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD0BnB;AAzBJ,uBAAuB;AACvB,uBAA2B;AAI3B,MAAM,mBAAe,yBAAO,2BAAU;AAAA;AAAA,WAE3B,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AA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xs } from "react/jsx-runtime";
|
|
3
|
-
import { useLayoutEffect, useRef, useState
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { noop } from "lodash";
|
|
5
|
-
import { describe, PropTypes } from "@elliemae/ds-utilities";
|
|
5
|
+
import { describe, PropTypes, useOnElementResize } from "@elliemae/ds-utilities";
|
|
6
6
|
import { styled } from "@elliemae/ds-system";
|
|
7
7
|
import { DSTooltipV3 } from "@elliemae/ds-tooltip";
|
|
8
8
|
import { buttonTypes } from "@elliemae/ds-button";
|
|
@@ -18,6 +18,24 @@ const Text = styled.span`
|
|
|
18
18
|
hyphens: auto;
|
|
19
19
|
word-break: break-all;
|
|
20
20
|
`;
|
|
21
|
+
const overflows = ({ offsetHeight, scrollHeight }) => offsetHeight + 2 < scrollHeight;
|
|
22
|
+
const binSearchTextOverflow = (element, parent, content) => {
|
|
23
|
+
const text = element.innerText;
|
|
24
|
+
let left = 1;
|
|
25
|
+
let right = text.length;
|
|
26
|
+
let textEnd = 0;
|
|
27
|
+
while (left <= right) {
|
|
28
|
+
const middle = (left + right) / 2;
|
|
29
|
+
element.innerText = content.slice(0, middle);
|
|
30
|
+
if (overflows(parent))
|
|
31
|
+
right = middle - 1;
|
|
32
|
+
else {
|
|
33
|
+
left = middle + 1;
|
|
34
|
+
textEnd = middle;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
element.innerText = content.slice(0, textEnd);
|
|
38
|
+
};
|
|
21
39
|
const DSReadMore = (props) => {
|
|
22
40
|
const {
|
|
23
41
|
lines = 2,
|
|
@@ -29,41 +47,22 @@ const DSReadMore = (props) => {
|
|
|
29
47
|
ellipsis = "...",
|
|
30
48
|
withTooltip = false
|
|
31
49
|
} = props;
|
|
32
|
-
const
|
|
50
|
+
const textRef = useRef(null);
|
|
51
|
+
const textWrapperRef = useRef(null);
|
|
33
52
|
const [showButton, setShowButton] = useState(false);
|
|
34
53
|
const [expanded, setExpanded] = useState(false);
|
|
35
|
-
const
|
|
36
|
-
const binSearchTextOverflow = useCallback(
|
|
37
|
-
(element, parent) => {
|
|
38
|
-
const text = element.innerText;
|
|
39
|
-
let left = 1;
|
|
40
|
-
let right = text.length;
|
|
41
|
-
let textEnd = 0;
|
|
42
|
-
while (left <= right) {
|
|
43
|
-
const middle = (left + right) / 2;
|
|
44
|
-
element.innerText = content.slice(0, middle);
|
|
45
|
-
if (overflows(parent))
|
|
46
|
-
right = middle - 1;
|
|
47
|
-
else {
|
|
48
|
-
left = middle + 1;
|
|
49
|
-
textEnd = middle;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
element.innerText = content.slice(0, textEnd);
|
|
53
|
-
},
|
|
54
|
-
[content]
|
|
55
|
-
);
|
|
54
|
+
const { width, height } = useOnElementResize(textWrapperRef);
|
|
56
55
|
useLayoutEffect(() => {
|
|
57
|
-
const textElement =
|
|
58
|
-
const parentElement =
|
|
56
|
+
const textElement = textRef.current;
|
|
57
|
+
const parentElement = textWrapperRef.current;
|
|
59
58
|
if (parentElement && textElement) {
|
|
60
59
|
textElement.innerText = content;
|
|
61
60
|
setShowButton(expanded || overflows(parentElement));
|
|
62
61
|
if (!expanded && overflows(parentElement)) {
|
|
63
|
-
binSearchTextOverflow(textElement, parentElement);
|
|
62
|
+
binSearchTextOverflow(textElement, parentElement, content);
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
|
-
}, [lines, content,
|
|
65
|
+
}, [lines, content, expanded, showButton, withTooltip, more, less, width, height]);
|
|
67
66
|
const toggleExpanded = (newExpanded) => {
|
|
68
67
|
setExpanded(newExpanded);
|
|
69
68
|
if (newExpanded)
|
|
@@ -71,42 +70,39 @@ const DSReadMore = (props) => {
|
|
|
71
70
|
else
|
|
72
71
|
onLess();
|
|
73
72
|
};
|
|
74
|
-
return /* @__PURE__ */ jsxs(Text, {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
ref,
|
|
80
|
-
"data-testid": "ds-read_more-text",
|
|
81
|
-
"aria-label": content,
|
|
82
|
-
children: content
|
|
83
|
-
}),
|
|
84
|
-
showButton && !withTooltip && /* @__PURE__ */ jsx(MoreLessButton, {
|
|
73
|
+
return /* @__PURE__ */ jsxs(Text, { ref: textWrapperRef, lines, expanded, children: [
|
|
74
|
+
/* @__PURE__ */ jsx("span", { ref: textRef, "data-testid": "ds-read_more-text", "aria-label": content, children: content }),
|
|
75
|
+
showButton && !withTooltip && /* @__PURE__ */ jsx(
|
|
76
|
+
MoreLessButton,
|
|
77
|
+
{
|
|
85
78
|
expanded,
|
|
86
79
|
label: expanded ? less : more,
|
|
87
80
|
onClick: () => toggleExpanded(!expanded),
|
|
88
81
|
ariaLabel: expanded ? less : more,
|
|
89
82
|
ellipsis,
|
|
90
83
|
dataTestId: "ds-read_more-button"
|
|
91
|
-
}
|
|
92
|
-
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
withTooltip && showButton && /* @__PURE__ */ jsx(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
93
89
|
style: {
|
|
94
90
|
display: "inline-block"
|
|
95
91
|
},
|
|
96
|
-
children: /* @__PURE__ */ jsx(DSTooltipV3, {
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
children: /* @__PURE__ */ jsx(DSTooltipV3, { text: content, children: /* @__PURE__ */ jsx(
|
|
93
|
+
MoreLessButton,
|
|
94
|
+
{
|
|
99
95
|
expanded,
|
|
100
96
|
label: "...",
|
|
101
97
|
ariaLabel: content,
|
|
102
98
|
ellipsis,
|
|
103
99
|
withTooltip,
|
|
104
100
|
dataTestId: "ds-read_more-tooltip-button"
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
});
|
|
101
|
+
}
|
|
102
|
+
) })
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] });
|
|
110
106
|
};
|
|
111
107
|
const DSReadMoreProps = {
|
|
112
108
|
lines: PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSReadMore.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { noop } from 'lodash';\nimport type { WeakValidationMap } from 'react';\nimport { describe, PropTypes, useOnElementResize } from '@elliemae/ds-utilities';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\n\nimport { buttonTypes } from '@elliemae/ds-button';\nimport { dsBasicSizes } from '@elliemae/ds-shared';\nimport { MoreLessButton } from './MoreLessButton';\nimport type { DSReadMoreT } from './index.d';\n\nconst Text = styled.span<{ lines: number; expanded: boolean }>`\n display: -webkit-box;\n -webkit-line-clamp: ${({ lines, expanded }) => (expanded ? 'unset' : lines)};\n -webkit-box-orient: vertical;\n -webkit-hyphens: auto;\n -moz-hyphens: auto;\n -ms-hyphens: auto;\n hyphens: auto;\n word-break: break-all;\n`;\n\n// offsetHeight + 2 takes into consideration any size of the button\nconst overflows = ({ offsetHeight, scrollHeight }: { offsetHeight: number; scrollHeight: number }) =>\n offsetHeight + 2 < scrollHeight;\n\n// Searchs the optimum cut on the text to have the button in the same line\nconst binSearchTextOverflow = (element: HTMLElement, parent: HTMLElement, content: string) => {\n const text = element.innerText;\n let left = 1;\n let right = text.length;\n let textEnd = 0;\n while (left <= right) {\n const middle = (left + right) / 2;\n element.innerText = content.slice(0, middle);\n if (overflows(parent)) right = middle - 1;\n else {\n left = middle + 1;\n textEnd = middle;\n }\n }\n element.innerText = content.slice(0, textEnd);\n};\n\nconst DSReadMore = (props: DSReadMoreT) => {\n const {\n lines = 2,\n more = 'more',\n less = 'less',\n onMore = noop,\n onLess = noop,\n content,\n ellipsis = '...',\n withTooltip = false,\n } = props;\n const textRef = useRef<HTMLSpanElement>(null);\n const textWrapperRef = useRef<HTMLSpanElement>(null);\n const [showButton, setShowButton] = useState(false);\n const [expanded, setExpanded] = useState(false);\n\n // We need to re-run the effect when the size of the container changes\n const { width, height } = useOnElementResize(textWrapperRef);\n\n useLayoutEffect(() => {\n const textElement = textRef.current;\n const parentElement = textWrapperRef.current;\n if (parentElement && textElement) {\n textElement.innerText = content;\n setShowButton(expanded || overflows(parentElement));\n if (!expanded && overflows(parentElement)) {\n binSearchTextOverflow(textElement, parentElement, content);\n }\n }\n }, [lines, content, expanded, showButton, withTooltip, more, less, width, height]);\n\n const toggleExpanded = (newExpanded: boolean) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n };\n\n return (\n <Text ref={textWrapperRef} lines={lines} expanded={expanded}>\n <span ref={textRef} data-testid=\"ds-read_more-text\" aria-label={content}>\n {content}\n </span>\n {showButton && !withTooltip && (\n <MoreLessButton\n expanded={expanded}\n label={expanded ? less : more}\n onClick={() => toggleExpanded(!expanded)}\n ariaLabel={expanded ? less : more}\n ellipsis={ellipsis}\n dataTestId=\"ds-read_more-button\"\n />\n )}\n {withTooltip && showButton && (\n <div\n style={{\n display: 'inline-block',\n }}\n >\n <DSTooltipV3 text={content}>\n <MoreLessButton\n expanded={expanded}\n label=\"...\"\n ariaLabel={content}\n ellipsis={ellipsis}\n withTooltip={withTooltip}\n dataTestId=\"ds-read_more-tooltip-button\"\n />\n </DSTooltipV3>\n </div>\n )}\n </Text>\n );\n};\n\nconst DSReadMoreProps = {\n /** Ammount of lines after you want to display an ellipsis + more/less button */\n lines: PropTypes.number\n .description('Ammount of lines after you want to display an ellipsis + more/less button')\n .defaultValue(2),\n /** Label which will appear on the 'More' button */\n more: PropTypes.string.description(\"Label which will appear on the 'More' button\").defaultValue('more'),\n /** Label which will appear on the 'Less' button */\n less: PropTypes.string.description(\"Label which will appear on the 'Less' button\").defaultValue('less'),\n /** Function which will execute when the user click the 'More' button */\n onMore: PropTypes.func.description(\"Function which will execute when the user click the 'More' button\"),\n /** Function which will execute when the user click the 'Less' button */\n onLess: PropTypes.func.description(\"Function which will execute when the user click the 'Less' button\"),\n /** The text content you want displayed */\n content: PropTypes.string.description('The text content you want displayed').isRequired,\n\n /** 'The type of button for more/less button' */\n buttonType: PropTypes.oneOf(buttonTypes).description('The type for the more/less button').defaultValue('link'),\n /**\n * ['s', 'm', 'l']\n */\n size: PropTypes.oneOf(dsBasicSizes as string[])\n .description('Size of the button')\n .defaultValue('s'),\n\n /** The text you want to appear when truncating */\n ellipsis: PropTypes.string.description('The text you want to appear when truncating').defaultValue('...'),\n withTooltip: PropTypes.bool\n .description('Whether to show expandable tooltip on ellipsis focus instead of expandable buttons')\n .defaultValue('false'),\n} as WeakValidationMap<unknown>;\n\nDSReadMore.propTypes = DSReadMoreProps;\n\nconst DSReadMoreWithSchema = describe(DSReadMore);\n\nDSReadMoreWithSchema.propTypes = DSReadMoreProps;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoFnB,SACE,KADF;AAnFJ,SAAgB,iBAAiB,QAAQ,gBAAgB;AACzD,SAAS,YAAY;AAErB,SAAS,UAAU,WAAW,0BAA0B;AACxD,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAG/B,MAAM,OAAO,OAAO;AAAA;AAAA,wBAEI,CAAC,EAAE,OAAO,SAAS,MAAO,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUvE,MAAM,YAAY,CAAC,EAAE,cAAc,aAAa,MAC9C,eAAe,IAAI;AAGrB,MAAM,wBAAwB,CAAC,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zB;AAEA,WAAW,YAAY;AAEvB,MAAM,uBAAuB,SAAS,UAAU;AAEhD,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -20,10 +20,11 @@ const StyledButton = styled(DSButtonV2)`
|
|
|
20
20
|
`;
|
|
21
21
|
const MoreLessButton = (props) => {
|
|
22
22
|
const { expanded, ariaLabel, label, onClick, ellipsis, withTooltip, dataTestId } = props;
|
|
23
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
return /* @__PURE__ */ jsxs("span", { children: [
|
|
24
|
+
expanded || withTooltip ? " " : ellipsis,
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
StyledButton,
|
|
27
|
+
{
|
|
27
28
|
withTooltip,
|
|
28
29
|
"aria-label": ariaLabel,
|
|
29
30
|
buttonType: "text",
|
|
@@ -32,9 +33,9 @@ const MoreLessButton = (props) => {
|
|
|
32
33
|
size: "s",
|
|
33
34
|
"data-testid": dataTestId,
|
|
34
35
|
children: label
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
});
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
] });
|
|
38
39
|
};
|
|
39
40
|
export {
|
|
40
41
|
MoreLessButton
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/MoreLessButton.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSButtonV2 } from '@elliemae/ds-button';\n\nimport type { MoreLessButtonT } from './index.d';\n\nconst StyledButton = styled(DSButtonV2)<{ withTooltip: boolean }>`\n padding: 0;\n color: ${({ withTooltip, theme }) => (withTooltip ? 'inherit' : `${theme.colors.brand['600']}`)};\n border: 0;\n margin: 0;\n font-size: 12px;\n font-weight: 200;\n min-width: 0px;\n height: auto;\n text-transform: unset;\n &:hover:not([disabled]) {\n color: ${({ withTooltip, theme }) => (withTooltip ? 'inherit' : `${theme.colors.brand['600']}`)};\n background-color: transparent;\n text-decoration: ${({ withTooltip }) => (withTooltip ? '' : 'underline')};\n }\n`;\nconst MoreLessButton = (props: MoreLessButtonT) => {\n const { expanded, ariaLabel, label, onClick, ellipsis, withTooltip, dataTestId } = props;\n\n return (\n <span>\n {expanded || withTooltip ? ' ' : ellipsis}\n\n <StyledButton\n withTooltip={withTooltip}\n aria-label={ariaLabel}\n buttonType=\"text\"\n onClick={onClick}\n aria-hidden\n size=\"s\"\n data-testid={dataTestId}\n >\n {label}\n </StyledButton>\n </span>\n );\n};\n\nexport { MoreLessButton };\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;AC0BnB,SAGE,KAHF;AAzBJ,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAI3B,MAAM,eAAe,OAAO,UAAU;AAAA;AAAA,WAE3B,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAS3E,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AAAA;AAAA,uBAEnE,CAAC,EAAE,YAAY,MAAO,cAAc,KAAK;AAAA;AAAA;AAGhE,MAAM,iBAAiB,CAAC,UAA2B;AACjD,QAAM,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,aAAa,WAAW,IAAI;AAEnF,SACE,qBAAC
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0BnB,SAGE,KAHF;AAzBJ,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAI3B,MAAM,eAAe,OAAO,UAAU;AAAA;AAAA,WAE3B,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAS3E,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AAAA;AAAA,uBAEnE,CAAC,EAAE,YAAY,MAAO,cAAc,KAAK;AAAA;AAAA;AAGhE,MAAM,iBAAiB,CAAC,UAA2B;AACjD,QAAM,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,aAAa,WAAW,IAAI;AAEnF,SACE,qBAAC,UACE;AAAA,gBAAY,cAAc,MAAM;AAAA,IAEjC;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,cAAY;AAAA,QACZ,YAAW;AAAA,QACX;AAAA,QACA,eAAW;AAAA,QACX,MAAK;AAAA,QACL,eAAa;AAAA,QAEZ;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-read-more",
|
|
3
|
-
"version": "3.12.0-rc.
|
|
3
|
+
"version": "3.12.0-rc.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Read More",
|
|
6
6
|
"files": [
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"indent": 4
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@elliemae/ds-button": "3.12.0-rc.
|
|
47
|
-
"@elliemae/ds-shared": "3.12.0-rc.
|
|
48
|
-
"@elliemae/ds-system": "3.12.0-rc.
|
|
49
|
-
"@elliemae/ds-tooltip": "3.12.0-rc.
|
|
50
|
-
"@elliemae/ds-utilities": "3.12.0-rc.
|
|
46
|
+
"@elliemae/ds-button": "3.12.0-rc.3",
|
|
47
|
+
"@elliemae/ds-shared": "3.12.0-rc.3",
|
|
48
|
+
"@elliemae/ds-system": "3.12.0-rc.3",
|
|
49
|
+
"@elliemae/ds-tooltip": "3.12.0-rc.3",
|
|
50
|
+
"@elliemae/ds-utilities": "3.12.0-rc.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "~8.19.0",
|