@elliemae/ds-read-more 3.3.0 → 3.3.1-rc.2
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/esm/DSReadMore.js +0 -1
- package/dist/esm/DSReadMore.js.map +1 -1
- package/dist/esm/MoreLessButton.js +0 -1
- package/dist/esm/MoreLessButton.js.map +1 -1
- package/dist/esm/index.d.js +0 -1
- package/dist/esm/index.d.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +6 -6
package/dist/esm/DSReadMore.js
CHANGED
|
@@ -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": "
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAGA,MAAM,OAAO,OAAO;AAAA;AAAA,wBAEI,CAAC,EAAE,OAAO,eAAgB,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;A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ources": ["../../../../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": "
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAIA,MAAM,eAAe,OAAO,UAAU;AAAA;AAAA,WAE3B,CAAC,EAAE,aAAa,YAAa,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAS3E,CAAC,EAAE,aAAa,YAAa,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM;AAAA;AAAA,uBAEnE,CAAC,EAAE,kBAAmB,cAAc,KAAK;AAAA;AAAA;AAGhE,MAAM,iBAAiB,CAAC,UAA2B;AACjD,QAAM,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,aAAa,eAAe;AAEnF,SACE,qCAAC,cACE,YAAY,cAAc,MAAM,UAEjC,qCAAC;AAAA,IACC;AAAA,IACA,cAAY;AAAA,IACZ,YAAW;AAAA,IACX;AAAA,IACA,eAAW;AAAA,IACX,MAAK;AAAA,IACL,eAAa;AAAA,KAEZ,KACH,CACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.d.js
CHANGED
package/dist/esm/index.d.js.map
CHANGED
package/dist/esm/index.js
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": "
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
|
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.3.
|
|
3
|
+
"version": "3.3.1-rc.2",
|
|
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.3.
|
|
47
|
-
"@elliemae/ds-shared": "3.3.
|
|
48
|
-
"@elliemae/ds-system": "3.3.
|
|
49
|
-
"@elliemae/ds-tooltip": "3.3.
|
|
50
|
-
"@elliemae/ds-utilities": "3.3.
|
|
46
|
+
"@elliemae/ds-button": "3.3.1-rc.2",
|
|
47
|
+
"@elliemae/ds-shared": "3.3.1-rc.2",
|
|
48
|
+
"@elliemae/ds-system": "3.3.1-rc.2",
|
|
49
|
+
"@elliemae/ds-tooltip": "3.3.1-rc.2",
|
|
50
|
+
"@elliemae/ds-utilities": "3.3.1-rc.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "~8.13.0",
|