@elliemae/ds-read-more 3.4.2 → 3.4.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 +59 -44
- package/dist/cjs/DSReadMore.js.map +1 -1
- package/dist/cjs/MoreLessButton.js +20 -11
- package/dist/cjs/MoreLessButton.js.map +1 -1
- package/dist/cjs/index.d.js +4 -1
- package/dist/cjs/index.d.js.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/DSReadMore.js +55 -43
- package/dist/esm/DSReadMore.js.map +1 -1
- package/dist/esm/MoreLessButton.js +16 -10
- package/dist/esm/MoreLessButton.js.map +1 -1
- package/dist/esm/index.d.js.map +1 -1
- package/dist/esm/index.js.map +2 -2
- package/package.json +6 -6
package/dist/cjs/DSReadMore.js
CHANGED
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var DSReadMore_exports = {};
|
|
23
26
|
__export(DSReadMore_exports, {
|
|
@@ -27,7 +30,8 @@ __export(DSReadMore_exports, {
|
|
|
27
30
|
});
|
|
28
31
|
module.exports = __toCommonJS(DSReadMore_exports);
|
|
29
32
|
var React = __toESM(require("react"));
|
|
30
|
-
var
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_react = require("react");
|
|
31
35
|
var import_lodash = require("lodash");
|
|
32
36
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
33
37
|
var import_ds_system = require("@elliemae/ds-system");
|
|
@@ -60,23 +64,26 @@ const DSReadMore = (props) => {
|
|
|
60
64
|
const [showButton, setShowButton] = (0, import_react.useState)(false);
|
|
61
65
|
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
62
66
|
const overflows = ({ offsetHeight, scrollHeight }) => offsetHeight + 2 < scrollHeight;
|
|
63
|
-
const binSearchTextOverflow = (0, import_react.useCallback)(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
+
}
|
|
76
82
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
element.innerText = content.slice(0, textEnd);
|
|
84
|
+
},
|
|
85
|
+
[content]
|
|
86
|
+
);
|
|
80
87
|
(0, import_react.useLayoutEffect)(() => {
|
|
81
88
|
const textElement = ref.current;
|
|
82
89
|
const parentElement = ref.current?.parentElement;
|
|
@@ -95,34 +102,42 @@ const DSReadMore = (props) => {
|
|
|
95
102
|
else
|
|
96
103
|
onLess();
|
|
97
104
|
};
|
|
98
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
|
|
99
106
|
lines,
|
|
100
|
-
expanded
|
|
101
|
-
}, /* @__PURE__ */ import_react.default.createElement("span", {
|
|
102
|
-
ref,
|
|
103
|
-
"data-testid": "ds-read_more-text",
|
|
104
|
-
"aria-label": content
|
|
105
|
-
}, content), showButton && !withTooltip && /* @__PURE__ */ import_react.default.createElement(import_MoreLessButton.MoreLessButton, {
|
|
106
|
-
expanded,
|
|
107
|
-
label: expanded ? less : more,
|
|
108
|
-
onClick: () => toggleExpanded(!expanded),
|
|
109
|
-
ariaLabel: expanded ? less : more,
|
|
110
|
-
ellipsis,
|
|
111
|
-
dataTestId: "ds-read_more-button"
|
|
112
|
-
}), withTooltip && /* @__PURE__ */ import_react.default.createElement("div", {
|
|
113
|
-
style: {
|
|
114
|
-
display: "inline-block"
|
|
115
|
-
}
|
|
116
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_ds_tooltip.DSTooltipV3, {
|
|
117
|
-
text: content
|
|
118
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_MoreLessButton.MoreLessButton, {
|
|
119
107
|
expanded,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
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, {
|
|
116
|
+
expanded,
|
|
117
|
+
label: expanded ? less : more,
|
|
118
|
+
onClick: () => toggleExpanded(!expanded),
|
|
119
|
+
ariaLabel: expanded ? less : more,
|
|
120
|
+
ellipsis,
|
|
121
|
+
dataTestId: "ds-read_more-button"
|
|
122
|
+
}),
|
|
123
|
+
withTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
124
|
+
style: {
|
|
125
|
+
display: "inline-block"
|
|
126
|
+
},
|
|
127
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, {
|
|
128
|
+
text: content,
|
|
129
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MoreLessButton.MoreLessButton, {
|
|
130
|
+
expanded,
|
|
131
|
+
label: "...",
|
|
132
|
+
ariaLabel: content,
|
|
133
|
+
ellipsis,
|
|
134
|
+
withTooltip,
|
|
135
|
+
dataTestId: "ds-read_more-tooltip-button"
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
});
|
|
126
141
|
};
|
|
127
142
|
const DSReadMoreProps = {
|
|
128
143
|
lines: import_ds_utilities.PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSReadMore.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState, useCallback } from 'react';\nimport { noop } from 'lodash';\nimport type { WeakValidationMap } from 'react';\nimport { describe, PropTypes } 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 { 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\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 ref = useRef<HTMLElement>(null);\n const [showButton, setShowButton] = useState(false);\n const [expanded, setExpanded] = useState(false);\n\n // offsetHeight + 2 takes into consideration any size of the button\n const 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\n const binSearchTextOverflow = useCallback(\n (element: HTMLElement, parent: HTMLElement) => {\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 [content],\n );\n\n useLayoutEffect(() => {\n const textElement = ref.current;\n const parentElement = ref.current?.parentElement;\n if (parentElement && textElement) {\n textElement.innerText = content;\n setShowButton(expanded || overflows(parentElement));\n if (!expanded && overflows(parentElement)) {\n binSearchTextOverflow(textElement, parentElement);\n }\n }\n }, [lines, content, binSearchTextOverflow, expanded, showButton, withTooltip, more, less]);\n\n const toggleExpanded = (newExpanded: boolean) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n };\n\n return (\n <Text lines={lines} expanded={expanded}>\n <span ref={ref} 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 && (\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};\n\nDSReadMore.propTypes = DSReadMoreProps as WeakValidationMap<unknown>;\n\nconst DSReadMoreWithSchema = describe<DSReadMoreT>(DSReadMore);\n\nDSReadMoreWithSchema.propTypes = DSReadMoreProps;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAsE;A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AA,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,8BAAsB,UAAU;AAE7D,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var MoreLessButton_exports = {};
|
|
23
26
|
__export(MoreLessButton_exports, {
|
|
@@ -25,7 +28,7 @@ __export(MoreLessButton_exports, {
|
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(MoreLessButton_exports);
|
|
27
30
|
var React = __toESM(require("react"));
|
|
28
|
-
var
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
32
|
var import_ds_system = require("@elliemae/ds-system");
|
|
30
33
|
var import_ds_button = require("@elliemae/ds-button");
|
|
31
34
|
const StyledButton = (0, import_ds_system.styled)(import_ds_button.DSButtonV2)`
|
|
@@ -46,14 +49,20 @@ const StyledButton = (0, import_ds_system.styled)(import_ds_button.DSButtonV2)`
|
|
|
46
49
|
`;
|
|
47
50
|
const MoreLessButton = (props) => {
|
|
48
51
|
const { expanded, ariaLabel, label, onClick, ellipsis, withTooltip, dataTestId } = props;
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
53
|
+
children: [
|
|
54
|
+
expanded || withTooltip ? " " : ellipsis,
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledButton, {
|
|
56
|
+
withTooltip,
|
|
57
|
+
"aria-label": ariaLabel,
|
|
58
|
+
buttonType: "text",
|
|
59
|
+
onClick,
|
|
60
|
+
"aria-hidden": true,
|
|
61
|
+
size: "s",
|
|
62
|
+
"data-testid": dataTestId,
|
|
63
|
+
children: label
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
});
|
|
58
67
|
};
|
|
59
68
|
//# 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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,uBAAuB;AACvB,uBAA2B;AAI3B,MAAM,mBAAe,yBAAO,2BAAU;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,6CAAC;AAAA,IACE;AAAA,kBAAY,cAAc,MAAM;AAAA,MAEjC,4CAAC;AAAA,QACC;AAAA,QACA,cAAY;AAAA,QACZ,YAAW;AAAA,QACX;AAAA,QACA,eAAW;AAAA,QACX,MAAK;AAAA,QACL,eAAa;AAAA,QAEZ;AAAA,OACH;AAAA;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.d.js
CHANGED
|
@@ -13,7 +13,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
}
|
|
14
14
|
return to;
|
|
15
15
|
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
|
+
mod
|
|
19
|
+
));
|
|
17
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
21
|
var index_d_exports = {};
|
|
19
22
|
module.exports = __toCommonJS(index_d_exports);
|
package/dist/cjs/index.d.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.d.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["export interface DSReadMoreT {\n lines: number;\n more: string;\n less: string;\n onMore: () => void;\n onLess: () => void;\n content: string;\n ellipsis: string;\n withTooltip?: boolean;\n}\n\nexport interface MoreLessButtonT {\n expanded: boolean;\n label: string;\n onClick?: () => void;\n ellipsis: string;\n withTooltip?: boolean;\n ariaLabel: string;\n dataTestId: string;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,7 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
22
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
26
|
var src_exports = {};
|
|
24
27
|
__export(src_exports, {
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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 './DSReadMore';\nexport { default } from './DSReadMore';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc,yBAAd;AACA,wBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSReadMore.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useLayoutEffect, useRef, useState, useCallback } from "react";
|
|
3
4
|
import { noop } from "lodash";
|
|
4
5
|
import { describe, PropTypes } from "@elliemae/ds-utilities";
|
|
5
6
|
import { styled } from "@elliemae/ds-system";
|
|
@@ -32,23 +33,26 @@ const DSReadMore = (props) => {
|
|
|
32
33
|
const [showButton, setShowButton] = useState(false);
|
|
33
34
|
const [expanded, setExpanded] = useState(false);
|
|
34
35
|
const overflows = ({ offsetHeight, scrollHeight }) => offsetHeight + 2 < scrollHeight;
|
|
35
|
-
const binSearchTextOverflow = useCallback(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
}
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
element.innerText = content.slice(0, textEnd);
|
|
53
|
+
},
|
|
54
|
+
[content]
|
|
55
|
+
);
|
|
52
56
|
useLayoutEffect(() => {
|
|
53
57
|
const textElement = ref.current;
|
|
54
58
|
const parentElement = ref.current?.parentElement;
|
|
@@ -67,34 +71,42 @@ const DSReadMore = (props) => {
|
|
|
67
71
|
else
|
|
68
72
|
onLess();
|
|
69
73
|
};
|
|
70
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ jsxs(Text, {
|
|
71
75
|
lines,
|
|
72
|
-
expanded
|
|
73
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
74
|
-
ref,
|
|
75
|
-
"data-testid": "ds-read_more-text",
|
|
76
|
-
"aria-label": content
|
|
77
|
-
}, content), showButton && !withTooltip && /* @__PURE__ */ React2.createElement(MoreLessButton, {
|
|
78
|
-
expanded,
|
|
79
|
-
label: expanded ? less : more,
|
|
80
|
-
onClick: () => toggleExpanded(!expanded),
|
|
81
|
-
ariaLabel: expanded ? less : more,
|
|
82
|
-
ellipsis,
|
|
83
|
-
dataTestId: "ds-read_more-button"
|
|
84
|
-
}), withTooltip && /* @__PURE__ */ React2.createElement("div", {
|
|
85
|
-
style: {
|
|
86
|
-
display: "inline-block"
|
|
87
|
-
}
|
|
88
|
-
}, /* @__PURE__ */ React2.createElement(DSTooltipV3, {
|
|
89
|
-
text: content
|
|
90
|
-
}, /* @__PURE__ */ React2.createElement(MoreLessButton, {
|
|
91
76
|
expanded,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsx("span", {
|
|
79
|
+
ref,
|
|
80
|
+
"data-testid": "ds-read_more-text",
|
|
81
|
+
"aria-label": content,
|
|
82
|
+
children: content
|
|
83
|
+
}),
|
|
84
|
+
showButton && !withTooltip && /* @__PURE__ */ jsx(MoreLessButton, {
|
|
85
|
+
expanded,
|
|
86
|
+
label: expanded ? less : more,
|
|
87
|
+
onClick: () => toggleExpanded(!expanded),
|
|
88
|
+
ariaLabel: expanded ? less : more,
|
|
89
|
+
ellipsis,
|
|
90
|
+
dataTestId: "ds-read_more-button"
|
|
91
|
+
}),
|
|
92
|
+
withTooltip && /* @__PURE__ */ jsx("div", {
|
|
93
|
+
style: {
|
|
94
|
+
display: "inline-block"
|
|
95
|
+
},
|
|
96
|
+
children: /* @__PURE__ */ jsx(DSTooltipV3, {
|
|
97
|
+
text: content,
|
|
98
|
+
children: /* @__PURE__ */ jsx(MoreLessButton, {
|
|
99
|
+
expanded,
|
|
100
|
+
label: "...",
|
|
101
|
+
ariaLabel: content,
|
|
102
|
+
ellipsis,
|
|
103
|
+
withTooltip,
|
|
104
|
+
dataTestId: "ds-read_more-tooltip-button"
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
98
110
|
};
|
|
99
111
|
const DSReadMoreProps = {
|
|
100
112
|
lines: PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSReadMore.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useLayoutEffect, useRef, useState, useCallback } from 'react';\nimport { noop } from 'lodash';\nimport type { WeakValidationMap } from 'react';\nimport { describe, PropTypes } 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 { 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\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 ref = useRef<HTMLElement>(null);\n const [showButton, setShowButton] = useState(false);\n const [expanded, setExpanded] = useState(false);\n\n // offsetHeight + 2 takes into consideration any size of the button\n const 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\n const binSearchTextOverflow = useCallback(\n (element: HTMLElement, parent: HTMLElement) => {\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 [content],\n );\n\n useLayoutEffect(() => {\n const textElement = ref.current;\n const parentElement = ref.current?.parentElement;\n if (parentElement && textElement) {\n textElement.innerText = content;\n setShowButton(expanded || overflows(parentElement));\n if (!expanded && overflows(parentElement)) {\n binSearchTextOverflow(textElement, parentElement);\n }\n }\n }, [lines, content, binSearchTextOverflow, expanded, showButton, withTooltip, more, less]);\n\n const toggleExpanded = (newExpanded: boolean) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n };\n\n return (\n <Text lines={lines} expanded={expanded}>\n <span ref={ref} 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 && (\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};\n\nDSReadMore.propTypes = DSReadMoreProps as WeakValidationMap<unknown>;\n\nconst DSReadMoreWithSchema = describe<DSReadMoreT>(DSReadMore);\n\nDSReadMoreWithSchema.propTypes = DSReadMoreProps;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,iBAAiB,QAAQ,UAAU,mBAAmB;AACtE,SAAS,YAAY;AAErB,SAAS,UAAU,iBAAiB;AACpC,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;AASvE,MAAM,aAAa,CAAC,UAAuB;AACzC,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,WAAW;AAAA,IACX,cAAc;AAAA,EAChB,IAAI;AACJ,QAAM,MAAM,OAAoB,IAAI;AACpC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;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O;AAAA,QAC7B;AAAA,QACA,YAAW;AAAA,OACb;AAAA,MAED,eACC,oBAAC;AAAA,QACC,OAAO;AAAA,UACL,SAAS;AAAA,QACX;AAAA,QAEA,8BAAC;AAAA,UAAY,MAAM;AAAA,UACjB,8BAAC;AAAA,YACC;AAAA,YACA,OAAM;AAAA,YACN,WAAW;AAAA,YACX;AAAA,YACA;AAAA,YACA,YAAW;AAAA,WACb;AAAA,SACF;AAAA,OACF;AAAA;AAAA,GAEJ;AAEJ;AAEA,MAAM,kBAAkB;AAAA,EAEtB,OAAO,UAAU,OACd,YAAY,2EAA2E,EACvF,aAAa,CAAC;AAAA,EAEjB,MAAM,UAAU,OAAO,YAAY,8CAA8C,EAAE,aAAa,MAAM;AAAA,EAEtG,MAAM,UAAU,OAAO,YAAY,8CAA8C,EAAE,aAAa,MAAM;AAAA,EAEtG,QAAQ,UAAU,KAAK,YAAY,mEAAmE;AAAA,EAEtG,QAAQ,UAAU,KAAK,YAAY,mEAAmE;AAAA,EAEtG,SAAS,UAAU,OAAO,YAAY,qCAAqC,EAAE;AAAA,EAG7E,YAAY,UAAU,MAAM,WAAW,EAAE,YAAY,mCAAmC,EAAE,aAAa,MAAM;AAAA,EAI7G,MAAM,UAAU,MAAM,YAAwB,EAC3C,YAAY,oBAAoB,EAChC,aAAa,GAAG;AAAA,EAGnB,UAAU,UAAU,OAAO,YAAY,6CAA6C,EAAE,aAAa,KAAK;AAAA,EACxG,aAAa,UAAU,KACpB,YAAY,oFAAoF,EAChG,aAAa,OAAO;AACzB;AAEA,WAAW,YAAY;AAEvB,MAAM,uBAAuB,SAAsB,UAAU;AAE7D,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { styled } from "@elliemae/ds-system";
|
|
4
4
|
import { DSButtonV2 } from "@elliemae/ds-button";
|
|
5
5
|
const StyledButton = styled(DSButtonV2)`
|
|
@@ -20,15 +20,21 @@ 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__ */
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
24
|
+
children: [
|
|
25
|
+
expanded || withTooltip ? " " : ellipsis,
|
|
26
|
+
/* @__PURE__ */ jsx(StyledButton, {
|
|
27
|
+
withTooltip,
|
|
28
|
+
"aria-label": ariaLabel,
|
|
29
|
+
buttonType: "text",
|
|
30
|
+
onClick,
|
|
31
|
+
"aria-hidden": true,
|
|
32
|
+
size: "s",
|
|
33
|
+
"data-testid": dataTestId,
|
|
34
|
+
children: label
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
});
|
|
32
38
|
};
|
|
33
39
|
export {
|
|
34
40
|
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;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,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;AAAA,IACE;AAAA,kBAAY,cAAc,MAAM;AAAA,MAEjC,oBAAC;AAAA,QACC;AAAA,QACA,cAAY;AAAA,QACZ,YAAW;AAAA,QACX;AAAA,QACA,eAAW;AAAA,QACX,MAAK;AAAA,QACL,eAAa;AAAA,QAEZ;AAAA,OACH;AAAA;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.d.js.map
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSReadMore';\nexport { default } from './DSReadMore';\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;AACd,SAAS,WAAAA,gBAAe;",
|
|
6
|
+
"names": ["default"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-read-more",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.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.4.
|
|
47
|
-
"@elliemae/ds-shared": "3.4.
|
|
48
|
-
"@elliemae/ds-system": "3.4.
|
|
49
|
-
"@elliemae/ds-tooltip": "3.4.
|
|
50
|
-
"@elliemae/ds-utilities": "3.4.
|
|
46
|
+
"@elliemae/ds-button": "3.4.3",
|
|
47
|
+
"@elliemae/ds-shared": "3.4.3",
|
|
48
|
+
"@elliemae/ds-system": "3.4.3",
|
|
49
|
+
"@elliemae/ds-tooltip": "3.4.3",
|
|
50
|
+
"@elliemae/ds-utilities": "3.4.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "~8.13.0",
|