@elliemae/ds-read-more 3.18.1 → 3.19.0

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.
Files changed (40) hide show
  1. package/dist/cjs/DSReadMore.js +66 -117
  2. package/dist/cjs/DSReadMore.js.map +2 -2
  3. package/dist/cjs/{index.d.js → DSReadMoreDefinitions.js} +27 -3
  4. package/dist/cjs/DSReadMoreDefinitions.js.map +7 -0
  5. package/dist/cjs/MoreLessButton.js +16 -21
  6. package/dist/cjs/MoreLessButton.js.map +2 -2
  7. package/dist/cjs/index.js +11 -4
  8. package/dist/cjs/index.js.map +3 -3
  9. package/dist/cjs/react-desc-prop-types.js +71 -0
  10. package/dist/cjs/react-desc-prop-types.js.map +7 -0
  11. package/dist/cjs/styled.js +73 -0
  12. package/dist/cjs/styled.js.map +7 -0
  13. package/dist/cjs/useReadMoreTruncate.js +95 -0
  14. package/dist/cjs/useReadMoreTruncate.js.map +7 -0
  15. package/dist/esm/DSReadMore.js +68 -119
  16. package/dist/esm/DSReadMore.js.map +2 -2
  17. package/dist/esm/DSReadMoreDefinitions.js +22 -0
  18. package/dist/esm/DSReadMoreDefinitions.js.map +7 -0
  19. package/dist/esm/MoreLessButton.js +15 -20
  20. package/dist/esm/MoreLessButton.js.map +2 -2
  21. package/dist/esm/index.js +10 -2
  22. package/dist/esm/index.js.map +2 -2
  23. package/dist/esm/react-desc-prop-types.js +46 -0
  24. package/dist/esm/react-desc-prop-types.js.map +7 -0
  25. package/dist/esm/styled.js +43 -0
  26. package/dist/esm/styled.js.map +7 -0
  27. package/dist/esm/useReadMoreTruncate.js +65 -0
  28. package/dist/esm/useReadMoreTruncate.js.map +7 -0
  29. package/dist/types/DSReadMore.d.ts +4 -5
  30. package/dist/types/DSReadMoreDefinitions.d.ts +12 -0
  31. package/dist/types/MoreLessButton.d.ts +12 -2
  32. package/dist/types/index.d.ts +4 -1
  33. package/dist/types/react-desc-prop-types.d.ts +26 -0
  34. package/dist/types/styled.d.ts +11 -0
  35. package/dist/types/useReadMoreTruncate.d.ts +16 -0
  36. package/package.json +6 -7
  37. package/dist/cjs/index.d.js.map +0 -7
  38. package/dist/esm/index.d.js +0 -2
  39. package/dist/esm/index.d.js.map +0 -7
  40. package/dist/types/index.d.d.ts +0 -19
@@ -36,135 +36,84 @@ module.exports = __toCommonJS(DSReadMore_exports);
36
36
  var React = __toESM(require("react"));
37
37
  var import_jsx_runtime = require("react/jsx-runtime");
38
38
  var import_react = require("react");
39
- var import_ds_utilities = require("@elliemae/ds-utilities");
40
39
  var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
41
- var import_ds_system = require("@elliemae/ds-system");
42
40
  var import_ds_tooltip = require("@elliemae/ds-tooltip");
43
- var import_ds_shared = require("@elliemae/ds-shared");
44
41
  var import_MoreLessButton = require("./MoreLessButton.js");
45
- const Text = import_ds_system.styled.span`
46
- display: -webkit-box;
47
- -webkit-line-clamp: ${({ lines, expanded }) => expanded ? "unset" : lines};
48
- -webkit-box-orient: vertical;
49
- -webkit-hyphens: auto;
50
- -moz-hyphens: auto;
51
- -ms-hyphens: auto;
52
- hyphens: auto;
53
- word-break: break-all;
54
- `;
55
- const overflows = ({ offsetHeight, scrollHeight }) => offsetHeight + 2 < scrollHeight;
56
- const binSearchTextOverflow = (element, parent, content) => {
57
- const text = element.innerText;
58
- let left = 1;
59
- let right = text.length;
60
- let textEnd = 0;
61
- while (left <= right) {
62
- const middle = (left + right) / 2;
63
- element.innerText = content.slice(0, middle);
64
- if (overflows(parent))
65
- right = middle - 1;
66
- else {
67
- left = middle + 1;
68
- textEnd = middle;
69
- }
70
- }
71
- element.innerText = content.slice(0, textEnd);
72
- };
73
- const noop = () => {
74
- };
42
+ var import_react_desc_prop_types = require("./react-desc-prop-types.js");
43
+ var import_styled = require("./styled.js");
44
+ var import_useReadMoreTruncate = require("./useReadMoreTruncate.js");
45
+ var import_DSReadMoreDefinitions = require("./DSReadMoreDefinitions.js");
75
46
  const DSReadMore = (props) => {
76
- const {
77
- lines = 2,
78
- more = "more",
79
- less = "less",
80
- onMore = noop,
81
- onLess = noop,
82
- content,
83
- ellipsis = "...",
84
- withTooltip = false
85
- } = props;
86
- const textRef = (0, import_react.useRef)(null);
87
- const textWrapperRef = (0, import_react.useRef)(null);
88
- const [showButton, setShowButton] = (0, import_react.useState)(false);
89
- const [expanded, setExpanded] = (0, import_react.useState)(false);
90
- const { width, height } = (0, import_ds_utilities.useOnElementResize)(textWrapperRef);
91
- (0, import_react.useLayoutEffect)(() => {
92
- const textElement = textRef.current;
93
- const parentElement = textWrapperRef.current;
94
- if (parentElement && textElement) {
95
- textElement.innerText = content;
96
- setShowButton(expanded || overflows(parentElement));
97
- if (!expanded && overflows(parentElement)) {
98
- binSearchTextOverflow(textElement, parentElement, content);
99
- }
100
- }
101
- }, [lines, content, expanded, showButton, withTooltip, more, less, width, height]);
102
- const toggleExpanded = (newExpanded) => {
103
- setExpanded(newExpanded);
104
- if (newExpanded)
105
- onMore();
106
- else
107
- onLess();
108
- };
109
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { ref: textWrapperRef, lines, expanded, children: [
110
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref: textRef, "data-testid": "ds-read_more-text", "aria-label": content, children: content }),
111
- showButton && !withTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
- import_MoreLessButton.MoreLessButton,
113
- {
114
- expanded,
115
- label: expanded ? less : more,
116
- onClick: () => toggleExpanded(!expanded),
117
- ariaLabel: expanded ? less : more,
118
- ellipsis,
119
- dataTestId: "ds-read_more-button"
120
- }
121
- ),
122
- withTooltip && showButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
123
- "div",
124
- {
125
- style: {
126
- display: "inline-block"
127
- },
128
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, { text: content, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
+ const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
48
+ const { lines, more, less, content, withTooltip, ellipsis, onMore, onLess } = propsWithDefault;
49
+ const xstyledProps = (0, import_ds_props_helpers.useGetXstyledProps)(propsWithDefault);
50
+ const { textWrapperRef, textRef, showButton, expanded, setExpanded, textWrapperProps, textProps } = (0, import_useReadMoreTruncate.useReadMoreTruncate)(propsWithDefault);
51
+ const toggleExpanded = (0, import_react.useCallback)(
52
+ (newExpanded) => {
53
+ setExpanded(newExpanded);
54
+ if (newExpanded)
55
+ onMore();
56
+ else
57
+ onLess();
58
+ },
59
+ [onMore, onLess, setExpanded]
60
+ );
61
+ const getOwnerProps = (0, import_react.useCallback)(() => propsWithDefault, [propsWithDefault]);
62
+ const getOwnerPropsArguments = (0, import_react.useCallback)(() => ({}), []);
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
64
+ import_styled.StyledTextWrapper,
65
+ {
66
+ ref: textWrapperRef,
67
+ lines,
68
+ expanded,
69
+ ...textWrapperProps,
70
+ getOwnerProps,
71
+ getOwnerPropsArguments,
72
+ ...xstyledProps,
73
+ children: [
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ import_styled.StyledTextContent,
76
+ {
77
+ ref: textRef,
78
+ "data-testid": "ds-read_more-text",
79
+ ...textProps,
80
+ getOwnerProps,
81
+ getOwnerPropsArguments,
82
+ children: content
83
+ }
84
+ ),
85
+ showButton && !withTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
+ import_MoreLessButton.MoreLessButton,
87
+ {
88
+ expanded,
89
+ label: expanded ? less : more,
90
+ onClick: () => toggleExpanded(!expanded),
91
+ ariaLabel: expanded ? "Read less" : "Read more",
92
+ ellipsis,
93
+ dataTestId: import_DSReadMoreDefinitions.DSReadMoreDataTestIds.READ_MORE_BUTTON,
94
+ getOwnerProps,
95
+ getOwnerPropsArguments
96
+ }
97
+ ),
98
+ withTooltip && showButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledTooltipWrapper, { getOwnerProps, getOwnerPropsArguments, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, { text: content, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
129
99
  import_MoreLessButton.MoreLessButton,
130
100
  {
131
101
  expanded,
132
102
  label: "...",
133
- ariaLabel: content,
103
+ ariaLabel: expanded ? "Read less" : "Read more",
134
104
  ellipsis,
135
105
  withTooltip,
136
- dataTestId: "ds-read_more-tooltip-button"
106
+ dataTestId: import_DSReadMoreDefinitions.DSReadMoreDataTestIds.READ_MORE_TOOLTIP_BUTTON,
107
+ getOwnerProps,
108
+ getOwnerPropsArguments
137
109
  }
138
- ) })
139
- }
140
- )
141
- ] });
142
- };
143
- const DSReadMoreProps = {
144
- /** Ammount of lines after you want to display an ellipsis + more/less button */
145
- lines: import_ds_props_helpers.PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
146
- /** Label which will appear on the 'More' button */
147
- more: import_ds_props_helpers.PropTypes.string.description("Label which will appear on the 'More' button").defaultValue("more"),
148
- /** Label which will appear on the 'Less' button */
149
- less: import_ds_props_helpers.PropTypes.string.description("Label which will appear on the 'Less' button").defaultValue("less"),
150
- /** Function which will execute when the user click the 'More' button */
151
- onMore: import_ds_props_helpers.PropTypes.func.description("Function which will execute when the user click the 'More' button"),
152
- /** Function which will execute when the user click the 'Less' button */
153
- onLess: import_ds_props_helpers.PropTypes.func.description("Function which will execute when the user click the 'Less' button"),
154
- /** The text content you want displayed */
155
- content: import_ds_props_helpers.PropTypes.string.description("The text content you want displayed").isRequired,
156
- /** 'The type of button for more/less button' */
157
- buttonType: import_ds_props_helpers.PropTypes.oneOf(["primary", "secondary", "text", "link"]).description("The type for the more/less button").defaultValue("link"),
158
- /**
159
- * ['s', 'm', 'l']
160
- */
161
- size: import_ds_props_helpers.PropTypes.oneOf(import_ds_shared.dsBasicSizes).description("Size of the button").defaultValue("s"),
162
- /** The text you want to appear when truncating */
163
- ellipsis: import_ds_props_helpers.PropTypes.string.description("The text you want to appear when truncating").defaultValue("..."),
164
- withTooltip: import_ds_props_helpers.PropTypes.bool.description("Whether to show expandable tooltip on ellipsis focus instead of expandable buttons").defaultValue("false")
110
+ ) }) })
111
+ ]
112
+ }
113
+ );
165
114
  };
166
- DSReadMore.propTypes = DSReadMoreProps;
115
+ DSReadMore.displayName = import_DSReadMoreDefinitions.DSReadMoreName;
167
116
  const DSReadMoreWithSchema = (0, import_ds_props_helpers.describe)(DSReadMore);
168
- DSReadMoreWithSchema.propTypes = DSReadMoreProps;
117
+ DSReadMoreWithSchema.propTypes = import_react_desc_prop_types.DSReadMorePropTypesSchema;
169
118
  var DSReadMore_default = DSReadMore;
170
119
  //# 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 { 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;AAnF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EAAmE;AAAA;AAAA,EAEtG,QAAQ,kCAAU,KAAK,YAAY,mEAAmE;AAAA;AAAA,EAEtG,SAAS,kCAAU,OAAO,YAAY,qCAAqC,EAAE;AAAA;AAAA,EAG7E,YAAY,kCAAU,MAAM,CAAC,WAAW,aAAa,QAAQ,MAAM,CAAC,EACjE,YAAY,mCAAmC,EAC/C,aAAa,MAAM;AAAA;AAAA;AAAA;AAAA,EAItB,MAAM,kCAAU,MAAM,6BAAwB,EAC3C,YAAY,oBAAoB,EAChC,aAAa,GAAG;AAAA;AAAA,EAGnB,UAAU,kCAAU,OAAO,YAAY,6CAA6C,EAAE,aAAa,KAAK;AAAA,EACxG,aAAa,kCAAU,KACpB,YAAY,oFAAoF,EAChG,aAAa,OAAO;AACzB;AAEA,WAAW,YAAY;AAEvB,MAAM,2BAAuB,kCAAS,UAAU;AAEhD,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
4
+ "sourcesContent": ["import React, { useCallback } from 'react';\nimport { describe, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { MoreLessButton } from './MoreLessButton.js';\nimport { type DSReadMoreT, DSReadMorePropTypesSchema, defaultProps } from './react-desc-prop-types.js';\nimport { StyledTextWrapper, StyledTextContent, StyledTooltipWrapper } from './styled.js';\nimport { useReadMoreTruncate } from './useReadMoreTruncate.js';\nimport { DSReadMoreDataTestIds, DSReadMoreName } from './DSReadMoreDefinitions.js';\n\nconst DSReadMore = (props: DSReadMoreT.Props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSReadMoreT.InternalProps>(props, defaultProps);\n const { lines, more, less, content, withTooltip, ellipsis, onMore, onLess } = propsWithDefault;\n\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const { textWrapperRef, textRef, showButton, expanded, setExpanded, textWrapperProps, textProps } =\n useReadMoreTruncate(propsWithDefault);\n\n const toggleExpanded = useCallback(\n (newExpanded: boolean) => {\n setExpanded(newExpanded);\n if (newExpanded) onMore();\n else onLess();\n },\n [onMore, onLess, setExpanded],\n );\n\n const getOwnerProps = useCallback(() => propsWithDefault, [propsWithDefault]);\n const getOwnerPropsArguments = useCallback(() => ({}), []);\n\n return (\n <StyledTextWrapper\n ref={textWrapperRef}\n lines={lines}\n expanded={expanded}\n {...textWrapperProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n {...xstyledProps}\n >\n <StyledTextContent\n ref={textRef}\n data-testid=\"ds-read_more-text\"\n {...textProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {content}\n </StyledTextContent>\n {showButton && !withTooltip && (\n <MoreLessButton\n expanded={expanded}\n label={expanded ? less : more}\n onClick={() => toggleExpanded(!expanded)}\n ariaLabel={expanded ? 'Read less' : 'Read more'}\n ellipsis={ellipsis}\n dataTestId={DSReadMoreDataTestIds.READ_MORE_BUTTON}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n )}\n {withTooltip && showButton && (\n <StyledTooltipWrapper getOwnerProps={getOwnerProps} getOwnerPropsArguments={getOwnerPropsArguments}>\n <DSTooltipV3 text={content}>\n <MoreLessButton\n expanded={expanded}\n label=\"...\"\n ariaLabel={expanded ? 'Read less' : 'Read more'}\n ellipsis={ellipsis}\n withTooltip={withTooltip}\n dataTestId={DSReadMoreDataTestIds.READ_MORE_TOOLTIP_BUTTON}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n </DSTooltipV3>\n </StyledTooltipWrapper>\n )}\n </StyledTextWrapper>\n );\n};\n\nDSReadMore.displayName = DSReadMoreName;\n\nconst DSReadMoreWithSchema = describe(DSReadMore);\n\nDSReadMoreWithSchema.propTypes = DSReadMorePropTypesSchema;\n\nexport { DSReadMore, DSReadMoreWithSchema };\nexport default DSReadMore;\n", "import * as React from 'react';\nexport { React };\n"],
5
+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AAAA,YACA,YAAY,mDAAsB;AAAA,YAClC;AAAA,YACA;AAAA;AAAA,QACF;AAAA,QAED,eAAe,cACd,4CAAC,sCAAqB,eAA8B,wBAClD,sDAAC,iCAAY,MAAM,SACjB;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,OAAM;AAAA,YACN,WAAW,WAAW,cAAc;AAAA,YACpC;AAAA,YACA;AAAA,YACA,YAAY,mDAAsB;AAAA,YAClC;AAAA,YACA;AAAA;AAAA,QACF,GACF,GACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,WAAW,cAAc;AAEzB,MAAM,2BAAuB,kCAAS,UAAU;AAEhD,qBAAqB,YAAY;AAGjC,IAAO,qBAAQ;",
6
6
  "names": []
7
7
  }
@@ -5,6 +5,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
8
12
  var __copyProps = (to, from, except, desc) => {
9
13
  if (from && typeof from === "object" || typeof from === "function") {
10
14
  for (let key of __getOwnPropNames(from))
@@ -22,7 +26,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
26
  mod
23
27
  ));
24
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
- var index_d_exports = {};
26
- module.exports = __toCommonJS(index_d_exports);
29
+ var DSReadMoreDefinitions_exports = {};
30
+ __export(DSReadMoreDefinitions_exports, {
31
+ DSReadMoreDataTestIds: () => DSReadMoreDataTestIds,
32
+ DSReadMoreName: () => DSReadMoreName,
33
+ DSReadMoreSlots: () => DSReadMoreSlots
34
+ });
35
+ module.exports = __toCommonJS(DSReadMoreDefinitions_exports);
27
36
  var React = __toESM(require("react"));
28
- //# sourceMappingURL=index.d.js.map
37
+ var import_lodash = require("lodash");
38
+ var import_ds_system = require("@elliemae/ds-system");
39
+ const DSReadMoreName = "DSReadMore";
40
+ const DSReadMoreSlots = {
41
+ ROOT: "root",
42
+ TEXT_CONTENT: "text-content",
43
+ TOOLTIP_WRAPPER: "tooltip-wrapper",
44
+ BUTTON_WRAPPER: "button-wrapper",
45
+ BUTTON: "button"
46
+ };
47
+ const DSReadMoreDataTestIds = {
48
+ ...(0, import_lodash.omit)((0, import_ds_system.slotObjectToDataTestIds)(DSReadMoreName, DSReadMoreSlots), "BUTTON"),
49
+ READ_MORE_BUTTON: "ds-read_more-button",
50
+ READ_MORE_TOOLTIP_BUTTON: "ds-read_more-tooltip-button"
51
+ };
52
+ //# sourceMappingURL=DSReadMoreDefinitions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/DSReadMoreDefinitions.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { omit } from 'lodash';\nimport { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSReadMoreName = 'DSReadMore';\n\nexport const DSReadMoreSlots = {\n ROOT: 'root',\n TEXT_CONTENT: 'text-content',\n TOOLTIP_WRAPPER: 'tooltip-wrapper',\n BUTTON_WRAPPER: 'button-wrapper',\n BUTTON: 'button',\n};\n\nexport const DSReadMoreDataTestIds = {\n ...omit(slotObjectToDataTestIds(DSReadMoreName, DSReadMoreSlots), 'BUTTON'),\n READ_MORE_BUTTON: 'ds-read_more-button',\n READ_MORE_TOOLTIP_BUTTON: 'ds-read_more-tooltip-button',\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,oBAAqB;AACrB,uBAAwC;AAEjC,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,QAAQ;AACV;AAEO,MAAM,wBAAwB;AAAA,EACnC,OAAG,wBAAK,0CAAwB,gBAAgB,eAAe,GAAG,QAAQ;AAAA,EAC1E,kBAAkB;AAAA,EAClB,0BAA0B;AAC5B;",
6
+ "names": []
7
+ }
@@ -33,37 +33,32 @@ __export(MoreLessButton_exports, {
33
33
  module.exports = __toCommonJS(MoreLessButton_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_ds_system = require("@elliemae/ds-system");
37
- var import_ds_button = require("@elliemae/ds-button");
38
- const StyledButton = (0, import_ds_system.styled)(import_ds_button.DSButtonV2)`
39
- padding: 0;
40
- color: ${({ withTooltip, theme }) => withTooltip ? "inherit" : `${theme.colors.brand["600"]}`};
41
- border: 0;
42
- margin: 0;
43
- font-size: 12px;
44
- min-width: 0px;
45
- height: auto;
46
- text-transform: unset;
47
- &:hover:not([disabled]) {
48
- color: ${({ withTooltip, theme }) => withTooltip ? "inherit" : `${theme.colors.brand["600"]}`};
49
- background-color: transparent;
50
- text-decoration: ${({ withTooltip }) => withTooltip ? "" : "underline"};
51
- }
52
- `;
36
+ var import_styled = require("./styled.js");
53
37
  const MoreLessButton = (props) => {
54
- const { expanded, ariaLabel, label, onClick, ellipsis, withTooltip, dataTestId } = props;
55
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
38
+ const {
39
+ expanded,
40
+ ariaLabel,
41
+ label,
42
+ onClick,
43
+ ellipsis,
44
+ withTooltip,
45
+ dataTestId,
46
+ getOwnerProps,
47
+ getOwnerPropsArguments
48
+ } = props;
49
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styled.StyledButtonWrapper, { getOwnerProps, getOwnerPropsArguments, children: [
56
50
  expanded || withTooltip ? " " : ellipsis,
57
51
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
- StyledButton,
52
+ import_styled.StyledButton,
59
53
  {
60
54
  withTooltip,
61
55
  "aria-label": ariaLabel,
62
56
  buttonType: "text",
63
57
  onClick,
64
- "aria-hidden": true,
65
58
  size: "s",
66
59
  "data-testid": dataTestId,
60
+ getOwnerProps,
61
+ getOwnerPropsArguments,
67
62
  children: label
68
63
  }
69
64
  )
@@ -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';\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,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAQhF,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM,KAAK;AAAA;AAAA,uBAExE,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;",
4
+ "sourcesContent": ["import React from 'react';\nimport { StyledButton, StyledButtonWrapper } from './styled.js';\n\ninterface MoreLessButtonProps {\n expanded: boolean;\n label: string;\n onClick?: () => void;\n ellipsis: string;\n withTooltip?: boolean;\n ariaLabel: string;\n dataTestId: string;\n getOwnerProps: () => object;\n getOwnerPropsArguments: () => object;\n}\n\nconst MoreLessButton = (props: MoreLessButtonProps) => {\n const {\n expanded,\n ariaLabel,\n label,\n onClick,\n ellipsis,\n withTooltip,\n dataTestId,\n getOwnerProps,\n getOwnerPropsArguments,\n } = props;\n\n return (\n <StyledButtonWrapper getOwnerProps={getOwnerProps} getOwnerPropsArguments={getOwnerPropsArguments}>\n {expanded || withTooltip ? ' ' : ellipsis}\n\n <StyledButton\n withTooltip={withTooltip}\n aria-label={ariaLabel}\n buttonType=\"text\"\n onClick={onClick}\n size=\"s\"\n data-testid={dataTestId}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {label}\n </StyledButton>\n </StyledButtonWrapper>\n );\n};\n\nexport { MoreLessButton };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD6BnB;AA5BJ,oBAAkD;AAclD,MAAM,iBAAiB,CAAC,UAA+B;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,SACE,6CAAC,qCAAoB,eAA8B,wBAChD;AAAA,gBAAY,cAAc,MAAM;AAAA,IAEjC;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,cAAY;AAAA,QACZ,YAAW;AAAA,QACX;AAAA,QACA,MAAK;AAAA,QACL,eAAa;AAAA,QACb;AAAA,QACA;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;",
6
6
  "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
21
  // If the importer is in node compatibility mode or this is not an ESM
23
22
  // file that has been converted to a CommonJS file using a Babel-
@@ -29,10 +28,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
29
  var src_exports = {};
31
30
  __export(src_exports, {
32
- default: () => import_DSReadMore.default
31
+ DSReadMore: () => import_DSReadMore.DSReadMore,
32
+ DSReadMoreDataTestIds: () => import_DSReadMoreDefinitions.DSReadMoreDataTestIds,
33
+ DSReadMoreName: () => import_DSReadMoreDefinitions.DSReadMoreName,
34
+ DSReadMoreSlots: () => import_DSReadMoreDefinitions.DSReadMoreSlots,
35
+ DSReadMoreWithSchema: () => import_DSReadMore.DSReadMoreWithSchema,
36
+ default: () => import_DSReadMore2.default,
37
+ useReadMoreTruncate: () => import_useReadMoreTruncate.useReadMoreTruncate
33
38
  });
34
39
  module.exports = __toCommonJS(src_exports);
35
40
  var React = __toESM(require("react"));
36
- __reExport(src_exports, require("./DSReadMore.js"), module.exports);
37
- var import_DSReadMore = __toESM(require("./DSReadMore.js"));
41
+ var import_DSReadMore = require("./DSReadMore.js");
42
+ var import_DSReadMoreDefinitions = require("./DSReadMoreDefinitions.js");
43
+ var import_useReadMoreTruncate = require("./useReadMoreTruncate.js");
44
+ var import_DSReadMore2 = __toESM(require("./DSReadMore.js"));
38
45
  //# sourceMappingURL=index.js.map
@@ -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.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
- "names": []
4
+ "sourcesContent": ["export { DSReadMore, DSReadMoreWithSchema } from './DSReadMore.js';\nexport { DSReadMoreName, DSReadMoreSlots, DSReadMoreDataTestIds } from './DSReadMoreDefinitions.js';\nexport type { DSReadMoreT } from './react-desc-prop-types.js';\nexport { useReadMoreTruncate } from './useReadMoreTruncate.js';\nexport { default } from './DSReadMore.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAiD;AACjD,mCAAuE;AAEvE,iCAAoC;AACpC,IAAAA,qBAAwB;",
6
+ "names": ["import_DSReadMore"]
7
7
  }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var react_desc_prop_types_exports = {};
30
+ __export(react_desc_prop_types_exports, {
31
+ DSReadMorePropTypes: () => DSReadMorePropTypes,
32
+ DSReadMorePropTypesSchema: () => DSReadMorePropTypesSchema,
33
+ defaultProps: () => defaultProps
34
+ });
35
+ module.exports = __toCommonJS(react_desc_prop_types_exports);
36
+ var React = __toESM(require("react"));
37
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
38
+ var import_DSReadMoreDefinitions = require("./DSReadMoreDefinitions.js");
39
+ const defaultProps = {
40
+ lines: 2,
41
+ more: "more",
42
+ less: "less",
43
+ onMore: () => {
44
+ },
45
+ onLess: () => {
46
+ },
47
+ ellipsis: "...",
48
+ withTooltip: false
49
+ };
50
+ const DSReadMorePropTypes = {
51
+ ...import_ds_props_helpers.globalAttributesPropTypes,
52
+ ...import_ds_props_helpers.xstyledPropTypes,
53
+ /** Ammount of lines after you want to display an ellipsis + more/less button */
54
+ lines: import_ds_props_helpers.PropTypes.number.description("Ammount of lines after you want to display an ellipsis + more/less button").defaultValue(2),
55
+ /** Label which will appear on the 'More' button */
56
+ more: import_ds_props_helpers.PropTypes.string.description("Label which will appear on the 'More' button").defaultValue("more"),
57
+ /** Label which will appear on the 'Less' button */
58
+ less: import_ds_props_helpers.PropTypes.string.description("Label which will appear on the 'Less' button").defaultValue("less"),
59
+ /** Function which will execute when the user click the 'More' button */
60
+ onMore: import_ds_props_helpers.PropTypes.func.description("Function which will execute when the user click the 'More' button"),
61
+ /** Function which will execute when the user click the 'Less' button */
62
+ onLess: import_ds_props_helpers.PropTypes.func.description("Function which will execute when the user click the 'Less' button"),
63
+ /** The text content you want displayed */
64
+ content: import_ds_props_helpers.PropTypes.string.description("The text content you want displayed").isRequired,
65
+ /** The text you want to appear when truncating */
66
+ ellipsis: import_ds_props_helpers.PropTypes.string.description("The text you want to appear when truncating").defaultValue("..."),
67
+ withTooltip: import_ds_props_helpers.PropTypes.bool.description("Whether to show expandable tooltip on ellipsis focus instead of expandable buttons").defaultValue("false"),
68
+ ...(0, import_ds_props_helpers.getPropsPerDatatestIdPropTypes)(import_DSReadMoreDefinitions.DSReadMoreDataTestIds)
69
+ };
70
+ const DSReadMorePropTypesSchema = DSReadMorePropTypes;
71
+ //# sourceMappingURL=react-desc-prop-types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport {\n getPropsPerDatatestIdPropTypes,\n globalAttributesPropTypes,\n PropTypes,\n xstyledPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { DSReadMoreDataTestIds } from './DSReadMoreDefinitions.js';\n\nexport namespace DSReadMoreT {\n type PropsT<D, R, O, E> = Partial<D> & R & O & Omit<GlobalAttributesT<E>, keyof D | keyof R | keyof O> & XstyledProps;\n type InternalPropsT<D, R, O, E> = D & R & O & Omit<GlobalAttributesT<E>, keyof D | keyof R | keyof O> & XstyledProps;\n\n export interface DefaultProps {\n lines: number;\n more: string;\n less: string;\n onMore: () => void;\n onLess: () => void;\n ellipsis: string;\n withTooltip: boolean;\n }\n\n export interface OptionalProps {}\n\n export interface RequiredProps {\n content: string;\n }\n\n export type Props = PropsT<DefaultProps, RequiredProps, OptionalProps, HTMLSpanElement>;\n\n export type InternalProps = InternalPropsT<DefaultProps, RequiredProps, OptionalProps, HTMLSpanElement>;\n}\n\nexport const defaultProps: DSReadMoreT.DefaultProps = {\n lines: 2,\n more: 'more',\n less: 'less',\n onMore: () => {},\n onLess: () => {},\n ellipsis: '...',\n withTooltip: false,\n};\n\nexport const DSReadMorePropTypes: DSPropTypesSchema<DSReadMoreT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\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 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 ...getPropsPerDatatestIdPropTypes(DSReadMoreDataTestIds),\n};\n\nexport const DSReadMorePropTypesSchema = DSReadMorePropTypes as unknown as WeakValidationMap<DSReadMoreT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAKO;AAGP,mCAAsC;AA2B/B,MAAM,eAAyC;AAAA,EACpD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ,MAAM;AAAA,EAAC;AAAA,EACf,QAAQ,MAAM;AAAA,EAAC;AAAA,EACf,UAAU;AAAA,EACV,aAAa;AACf;AAEO,MAAM,sBAA4D;AAAA,EACvE,GAAG;AAAA,EACH,GAAG;AAAA;AAAA,EAEH,OAAO,kCAAU,OACd,YAAY,2EAA2E,EACvF,aAAa,CAAC;AAAA;AAAA,EAEjB,MAAM,kCAAU,OAAO,YAAY,8CAA8C,EAAE,aAAa,MAAM;AAAA;AAAA,EAEtG,MAAM,kCAAU,OAAO,YAAY,8CAA8C,EAAE,aAAa,MAAM;AAAA;AAAA,EAEtG,QAAQ,kCAAU,KAAK,YAAY,mEAAmE;AAAA;AAAA,EAEtG,QAAQ,kCAAU,KAAK,YAAY,mEAAmE;AAAA;AAAA,EAEtG,SAAS,kCAAU,OAAO,YAAY,qCAAqC,EAAE;AAAA;AAAA,EAG7E,UAAU,kCAAU,OAAO,YAAY,6CAA6C,EAAE,aAAa,KAAK;AAAA,EACxG,aAAa,kCAAU,KACpB,YAAY,oFAAoF,EAChG,aAAa,OAAO;AAAA,EACvB,OAAG,wDAA+B,kDAAqB;AACzD;AAEO,MAAM,4BAA4B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var styled_exports = {};
30
+ __export(styled_exports, {
31
+ StyledButton: () => StyledButton,
32
+ StyledButtonWrapper: () => StyledButtonWrapper,
33
+ StyledTextContent: () => StyledTextContent,
34
+ StyledTextWrapper: () => StyledTextWrapper,
35
+ StyledTooltipWrapper: () => StyledTooltipWrapper
36
+ });
37
+ module.exports = __toCommonJS(styled_exports);
38
+ var React = __toESM(require("react"));
39
+ var import_ds_system = require("@elliemae/ds-system");
40
+ var import_ds_button = require("@elliemae/ds-button");
41
+ var import_DSReadMoreDefinitions = require("./DSReadMoreDefinitions.js");
42
+ const StyledTextWrapper = (0, import_ds_system.styled)("span", { name: import_DSReadMoreDefinitions.DSReadMoreName, slot: import_DSReadMoreDefinitions.DSReadMoreSlots.ROOT })`
43
+ display: -webkit-box;
44
+ -webkit-line-clamp: ${({ lines, expanded }) => expanded ? "unset" : lines};
45
+ -webkit-box-orient: vertical;
46
+ -webkit-hyphens: auto;
47
+ -moz-hyphens: auto;
48
+ -ms-hyphens: auto;
49
+ hyphens: auto;
50
+ word-break: break-all;
51
+ ${import_ds_system.xStyledCommonProps}
52
+ `;
53
+ const StyledTextContent = (0, import_ds_system.styled)("span", { name: import_DSReadMoreDefinitions.DSReadMoreName, slot: import_DSReadMoreDefinitions.DSReadMoreSlots.TEXT_CONTENT })``;
54
+ const StyledTooltipWrapper = (0, import_ds_system.styled)("div", { name: import_DSReadMoreDefinitions.DSReadMoreName, slot: import_DSReadMoreDefinitions.DSReadMoreSlots.TOOLTIP_WRAPPER })`
55
+ display: inline-block;
56
+ `;
57
+ const StyledButtonWrapper = (0, import_ds_system.styled)("span", { name: import_DSReadMoreDefinitions.DSReadMoreName, slot: import_DSReadMoreDefinitions.DSReadMoreSlots.BUTTON_WRAPPER })``;
58
+ const StyledButton = (0, import_ds_system.styled)(import_ds_button.DSButtonV2, { name: import_DSReadMoreDefinitions.DSReadMoreName, slot: import_DSReadMoreDefinitions.DSReadMoreSlots.BUTTON })`
59
+ padding: 0;
60
+ color: ${({ withTooltip, theme }) => withTooltip ? "inherit" : `${theme.colors.brand["600"]}`};
61
+ border: 0;
62
+ margin: 0;
63
+ font-size: 12px;
64
+ min-width: 0px;
65
+ height: auto;
66
+ text-transform: unset;
67
+ &:hover:not([disabled]) {
68
+ color: ${({ withTooltip, theme }) => withTooltip ? "inherit" : `${theme.colors.brand["600"]}`};
69
+ background-color: transparent;
70
+ text-decoration: ${({ withTooltip }) => withTooltip ? "" : "underline"};
71
+ }
72
+ `;
73
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/styled.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { styled, xStyledCommonProps } from '@elliemae/ds-system';\nimport { DSButtonV2 } from '@elliemae/ds-button';\nimport { DSReadMoreName, DSReadMoreSlots } from './DSReadMoreDefinitions.js';\n\nexport const StyledTextWrapper = styled('span', { name: DSReadMoreName, slot: DSReadMoreSlots.ROOT })<{\n lines: number;\n expanded: boolean;\n}>`\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 ${xStyledCommonProps}\n`;\n\nexport const StyledTextContent = styled('span', { name: DSReadMoreName, slot: DSReadMoreSlots.TEXT_CONTENT })``;\n\nexport const StyledTooltipWrapper = styled('div', { name: DSReadMoreName, slot: DSReadMoreSlots.TOOLTIP_WRAPPER })`\n display: inline-block;\n`;\n\nexport const StyledButtonWrapper = styled('span', { name: DSReadMoreName, slot: DSReadMoreSlots.BUTTON_WRAPPER })``;\n\nexport const StyledButton = styled(DSButtonV2, { name: DSReadMoreName, slot: DSReadMoreSlots.BUTTON })<{\n withTooltip?: boolean;\n}>`\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`;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA2C;AAC3C,uBAA2B;AAC3B,mCAAgD;AAEzC,MAAM,wBAAoB,yBAAO,QAAQ,EAAE,MAAM,6CAAgB,MAAM,6CAAgB,KAAK,CAAC;AAAA;AAAA,wBAK5E,CAAC,EAAE,OAAO,SAAS,MAAO,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnE;AAAA;AAGG,MAAM,wBAAoB,yBAAO,QAAQ,EAAE,MAAM,6CAAgB,MAAM,6CAAgB,aAAa,CAAC;AAErG,MAAM,2BAAuB,yBAAO,OAAO,EAAE,MAAM,6CAAgB,MAAM,6CAAgB,gBAAgB,CAAC;AAAA;AAAA;AAI1G,MAAM,0BAAsB,yBAAO,QAAQ,EAAE,MAAM,6CAAgB,MAAM,6CAAgB,eAAe,CAAC;AAEzG,MAAM,mBAAe,yBAAO,6BAAY,EAAE,MAAM,6CAAgB,MAAM,6CAAgB,OAAO,CAAC;AAAA;AAAA,WAI1F,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAQhF,CAAC,EAAE,aAAa,MAAM,MAAO,cAAc,YAAY,GAAG,MAAM,OAAO,MAAM,KAAK;AAAA;AAAA,uBAExE,CAAC,EAAE,YAAY,MAAO,cAAc,KAAK;AAAA;AAAA;",
6
+ "names": []
7
+ }