@elliemae/ds-read-more 3.15.0 → 3.16.0-next.10
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 +13 -12
- package/dist/cjs/DSReadMore.js.map +2 -2
- package/dist/cjs/MoreLessButton.js.map +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/package.json +7 -0
- package/dist/esm/DSReadMore.js +3 -2
- package/dist/esm/DSReadMore.js.map +2 -2
- package/dist/esm/MoreLessButton.js.map +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +7 -0
- package/dist/types/DSReadMore.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +8 -7
package/dist/cjs/DSReadMore.js
CHANGED
|
@@ -33,10 +33,11 @@ var React = __toESM(require("react"));
|
|
|
33
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
34
|
var import_react = require("react");
|
|
35
35
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
36
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
36
37
|
var import_ds_system = require("@elliemae/ds-system");
|
|
37
38
|
var import_ds_tooltip = require("@elliemae/ds-tooltip");
|
|
38
39
|
var import_ds_shared = require("@elliemae/ds-shared");
|
|
39
|
-
var import_MoreLessButton = require("./MoreLessButton");
|
|
40
|
+
var import_MoreLessButton = require("./MoreLessButton.js");
|
|
40
41
|
const Text = import_ds_system.styled.span`
|
|
41
42
|
display: -webkit-box;
|
|
42
43
|
-webkit-line-clamp: ${({ lines, expanded }) => expanded ? "unset" : lines};
|
|
@@ -136,19 +137,19 @@ const DSReadMore = (props) => {
|
|
|
136
137
|
] });
|
|
137
138
|
};
|
|
138
139
|
const DSReadMoreProps = {
|
|
139
|
-
lines:
|
|
140
|
-
more:
|
|
141
|
-
less:
|
|
142
|
-
onMore:
|
|
143
|
-
onLess:
|
|
144
|
-
content:
|
|
145
|
-
buttonType:
|
|
146
|
-
size:
|
|
147
|
-
ellipsis:
|
|
148
|
-
withTooltip:
|
|
140
|
+
lines: import_ds_props_helpers.PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
|
|
141
|
+
more: import_ds_props_helpers.PropTypes.string.description("Label which will appear on the 'More' button").defaultValue("more"),
|
|
142
|
+
less: import_ds_props_helpers.PropTypes.string.description("Label which will appear on the 'Less' button").defaultValue("less"),
|
|
143
|
+
onMore: import_ds_props_helpers.PropTypes.func.description("Function which will execute when the user click the 'More' button"),
|
|
144
|
+
onLess: import_ds_props_helpers.PropTypes.func.description("Function which will execute when the user click the 'Less' button"),
|
|
145
|
+
content: import_ds_props_helpers.PropTypes.string.description("The text content you want displayed").isRequired,
|
|
146
|
+
buttonType: import_ds_props_helpers.PropTypes.oneOf(["primary", "secondary", "text", "link"]).description("The type for the more/less button").defaultValue("link"),
|
|
147
|
+
size: import_ds_props_helpers.PropTypes.oneOf(import_ds_shared.dsBasicSizes).description("Size of the button").defaultValue("s"),
|
|
148
|
+
ellipsis: import_ds_props_helpers.PropTypes.string.description("The text you want to appear when truncating").defaultValue("..."),
|
|
149
|
+
withTooltip: import_ds_props_helpers.PropTypes.bool.description("Whether to show expandable tooltip on ellipsis focus instead of expandable buttons").defaultValue("false")
|
|
149
150
|
};
|
|
150
151
|
DSReadMore.propTypes = DSReadMoreProps;
|
|
151
|
-
const DSReadMoreWithSchema = (0,
|
|
152
|
+
const DSReadMoreWithSchema = (0, import_ds_props_helpers.describe)(DSReadMore);
|
|
152
153
|
DSReadMoreWithSchema.propTypes = DSReadMoreProps;
|
|
153
154
|
var DSReadMore_default = DSReadMore;
|
|
154
155
|
//# sourceMappingURL=DSReadMore.js.map
|
|
@@ -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 } from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { describe, PropTypes
|
|
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 type { WeakValidationMap } from 'react';\nimport { useOnElementResize } from '@elliemae/ds-utilities';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { dsBasicSizes } from '@elliemae/ds-shared';\nimport { MoreLessButton } from './MoreLessButton.js';\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 noop = () => {};\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(['primary', 'secondary', 'text', 'link'])\n .description('The type for the more/less button')\n .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": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoFnB;AAnFJ,mBAAyD;AAEzD,0BAAmC;AACnC,8BAAoC;AACpC,uBAAuB;AACvB,wBAA4B;AAC5B,uBAA6B;AAC7B,4BAA+B;AAG/B,MAAM,OAAO,wBAAO;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,SAAsB,QAAqB,YAAoB;AAC5F,QAAM,OAAO,QAAQ;AACrB,MAAI,OAAO;A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aAAa,OAAO;AACzB;AAEA,WAAW,YAAY;AAEvB,MAAM,2BAAuB,kCAAS,UAAU;AAEhD,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/MoreLessButton.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSButtonV2 } from '@elliemae/ds-button';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSButtonV2 } from '@elliemae/ds-button';\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 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;ADwBnB;AAvBJ,uBAAuB;AACvB,uBAA2B;AAG3B,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,aAQ3E,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,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/dist/cjs/index.js
CHANGED
|
@@ -29,6 +29,6 @@ __export(src_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(src_exports);
|
|
31
31
|
var React = __toESM(require("react"));
|
|
32
|
-
__reExport(src_exports, require("./DSReadMore"), module.exports);
|
|
33
|
-
var import_DSReadMore = __toESM(require("./DSReadMore"));
|
|
32
|
+
__reExport(src_exports, require("./DSReadMore.js"), module.exports);
|
|
33
|
+
var import_DSReadMore = __toESM(require("./DSReadMore.js"));
|
|
34
34
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export * from './DSReadMore';\nexport { default } from './DSReadMore';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc,
|
|
4
|
+
"sourcesContent": ["export * from './DSReadMore.js';\nexport { default } from './DSReadMore.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc,4BAAd;AACA,wBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSReadMore.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useOnElementResize } from "@elliemae/ds-utilities";
|
|
5
|
+
import { describe, PropTypes } from "@elliemae/ds-props-helpers";
|
|
5
6
|
import { styled } from "@elliemae/ds-system";
|
|
6
7
|
import { DSTooltipV3 } from "@elliemae/ds-tooltip";
|
|
7
8
|
import { dsBasicSizes } from "@elliemae/ds-shared";
|
|
8
|
-
import { MoreLessButton } from "./MoreLessButton";
|
|
9
|
+
import { MoreLessButton } from "./MoreLessButton.js";
|
|
9
10
|
const Text = styled.span`
|
|
10
11
|
display: -webkit-box;
|
|
11
12
|
-webkit-line-clamp: ${({ lines, expanded }) => expanded ? "unset" : lines};
|
|
@@ -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 } from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { describe, PropTypes
|
|
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 type { WeakValidationMap } from 'react';\nimport { useOnElementResize } from '@elliemae/ds-utilities';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { dsBasicSizes } from '@elliemae/ds-shared';\nimport { MoreLessButton } from './MoreLessButton.js';\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 noop = () => {};\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(['primary', 'secondary', 'text', 'link'])\n .description('The type for the more/less button')\n .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;AAEzD,SAAS,0BAA0B;AACnC,SAAS,UAAU,iBAAiB;AACpC,SAAS,cAAc;AACvB,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,SAAsB,QAAqB,YAAoB;AAC5F,QAAM,OAAO,QAAQ;AACrB,MAAI,OAAO;AACX,MAAI,QAAQ,KAAK;AACjB,MAAI,UAAU;AACd,SAAO,QA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hD,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/MoreLessButton.tsx"],
|
|
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';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
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';\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 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;ACwBnB,SAGE,KAHF;AAvBJ,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAG3B,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,aAQ3E,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/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSReadMore';\nexport { default } from './DSReadMore';\n"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSReadMore.js';\nexport { default } from './DSReadMore.js';\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;AACd,SAAS,WAAAA,gBAAe;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -4,6 +4,6 @@ declare const DSReadMore: {
|
|
|
4
4
|
(props: DSReadMoreT): JSX.Element;
|
|
5
5
|
propTypes: React.WeakValidationMap<unknown>;
|
|
6
6
|
};
|
|
7
|
-
declare const DSReadMoreWithSchema: import("@elliemae/ds-
|
|
7
|
+
declare const DSReadMoreWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<DSReadMoreT>;
|
|
8
8
|
export { DSReadMore, DSReadMoreWithSchema };
|
|
9
9
|
export default DSReadMore;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './DSReadMore';
|
|
2
|
-
export { default } from './DSReadMore';
|
|
1
|
+
export * from './DSReadMore.js';
|
|
2
|
+
export { default } from './DSReadMore.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-read-more",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Read More",
|
|
6
6
|
"files": [
|
|
@@ -43,11 +43,12 @@
|
|
|
43
43
|
"indent": 4
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@elliemae/ds-button": "3.
|
|
47
|
-
"@elliemae/ds-
|
|
48
|
-
"@elliemae/ds-
|
|
49
|
-
"@elliemae/ds-
|
|
50
|
-
"@elliemae/ds-
|
|
46
|
+
"@elliemae/ds-button": "3.16.0-next.10",
|
|
47
|
+
"@elliemae/ds-props-helpers": "3.16.0-next.10",
|
|
48
|
+
"@elliemae/ds-shared": "3.16.0-next.10",
|
|
49
|
+
"@elliemae/ds-system": "3.16.0-next.10",
|
|
50
|
+
"@elliemae/ds-tooltip": "3.16.0-next.10",
|
|
51
|
+
"@elliemae/ds-utilities": "3.16.0-next.10"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@testing-library/dom": "~8.19.0",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"eslint:fix": "eslint --ext='.js,.jsx,.test.js,.ts,.tsx' --fix --config='../../.eslintrc.js' src/",
|
|
73
74
|
"dts": "node ../../scripts/dts.mjs",
|
|
74
75
|
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs",
|
|
75
|
-
"dev:build": "pnpm --filter {.}... build
|
|
76
|
+
"dev:build": "pnpm --filter {.}... build",
|
|
76
77
|
"dev:install": "pnpm --filter {.}... i --no-lockfile && pnpm run dev:build",
|
|
77
78
|
"checkDeps": "npx -yes ../ds-codemods check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\""
|
|
78
79
|
}
|