@elliemae/ds-accordion 2.2.1 → 2.3.0-alpha.4

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 (56) hide show
  1. package/cjs/DSAccordion.js +50 -29
  2. package/cjs/DSAccordion.js.map +7 -0
  3. package/cjs/DSAccordionCTX.js +40 -14
  4. package/cjs/DSAccordionCTX.js.map +7 -0
  5. package/cjs/DSAccordionDatatestid.js +38 -10
  6. package/cjs/DSAccordionDatatestid.js.map +7 -0
  7. package/cjs/DSAccordionTypes.js +27 -2
  8. package/cjs/DSAccordionTypes.js.map +7 -0
  9. package/cjs/config/useAccordion.js +59 -36
  10. package/cjs/config/useAccordion.js.map +7 -0
  11. package/cjs/config/useAccordionRefs.js +46 -39
  12. package/cjs/config/useAccordionRefs.js.map +7 -0
  13. package/cjs/defaultProps.js +49 -39
  14. package/cjs/defaultProps.js.map +7 -0
  15. package/cjs/index.js +37 -14
  16. package/cjs/index.js.map +7 -0
  17. package/cjs/parts/accordionContent/AccordionContent.js +44 -35
  18. package/cjs/parts/accordionContent/AccordionContent.js.map +7 -0
  19. package/cjs/parts/accordionItem/DSAccordionItem.js +147 -174
  20. package/cjs/parts/accordionItem/DSAccordionItem.js.map +7 -0
  21. package/cjs/parts/accordionItem/styles.js +138 -144
  22. package/cjs/parts/accordionItem/styles.js.map +7 -0
  23. package/cjs/parts/accordionItem/useAccordionItem.js +52 -39
  24. package/cjs/parts/accordionItem/useAccordionItem.js.map +7 -0
  25. package/cjs/propTypes.js +53 -22
  26. package/cjs/propTypes.js.map +7 -0
  27. package/esm/DSAccordion.js +18 -16
  28. package/esm/DSAccordion.js.map +7 -0
  29. package/esm/DSAccordionCTX.js +10 -9
  30. package/esm/DSAccordionCTX.js.map +7 -0
  31. package/esm/DSAccordionDatatestid.js +9 -6
  32. package/esm/DSAccordionDatatestid.js.map +7 -0
  33. package/esm/DSAccordionTypes.js +2 -1
  34. package/esm/DSAccordionTypes.js.map +7 -0
  35. package/esm/config/useAccordion.js +25 -27
  36. package/esm/config/useAccordion.js.map +7 -0
  37. package/esm/config/useAccordionRefs.js +17 -31
  38. package/esm/config/useAccordionRefs.js.map +7 -0
  39. package/esm/defaultProps.js +21 -31
  40. package/esm/defaultProps.js.map +7 -0
  41. package/esm/index.js +8 -2
  42. package/esm/index.js.map +7 -0
  43. package/esm/parts/accordionContent/AccordionContent.js +14 -25
  44. package/esm/parts/accordionContent/AccordionContent.js.map +7 -0
  45. package/esm/parts/accordionItem/DSAccordionItem.js +114 -147
  46. package/esm/parts/accordionItem/DSAccordionItem.js.map +7 -0
  47. package/esm/parts/accordionItem/styles.js +112 -131
  48. package/esm/parts/accordionItem/styles.js.map +7 -0
  49. package/esm/parts/accordionItem/useAccordionItem.js +21 -33
  50. package/esm/parts/accordionItem/useAccordionItem.js.map +7 -0
  51. package/esm/propTypes.js +24 -17
  52. package/esm/propTypes.js.map +7 -0
  53. package/package.json +7 -11
  54. package/cjs/parts/accordionItem/useIsShowingEllipsis.js +0 -37
  55. package/esm/parts/accordionItem/useIsShowingEllipsis.js +0 -33
  56. package/types/parts/accordionItem/useIsShowingEllipsis.d.ts +0 -5
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/accordionItem/DSAccordionItem.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useState, useContext, useCallback, useMemo } from 'react';\nimport { describe } from 'react-desc';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { DSButton, BUTTON_TYPE } from '@elliemae/ds-button';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { useIsShowingEllipsis } from '@elliemae/ds-utilities';\nimport { accordionItemDefaultProps } from '../../defaultProps';\nimport {\n StyledItemAddon,\n StyledItemContainer,\n StyledItemContent,\n StyledItemCustomActions,\n StyledItemHeader,\n StyledItemHeaderContainer,\n StyledItemTitles,\n StyledPrimaryTitle,\n StyledSecondaryTitle,\n} from './styles';\nimport { accordionItemPropTypes } from '../../propTypes';\nimport { useAccordionItem } from './useAccordionItem';\nimport { DSAccordionContext } from '../../DSAccordionCTX';\nimport { DSAccordionDataTestid } from '../../DSAccordionDatatestid';\nimport type { DSAccordionItemPropsT, DSAccordionItemPropsWithDefaultsT } from '../../DSAccordionTypes';\n\nconst DSAccordionItem = (props: DSAccordionItemPropsT): JSX.Element => {\n const propsWithDefaults = useMemoMergePropsWithDefault(\n props,\n accordionItemDefaultProps,\n ) as DSAccordionItemPropsWithDefaultsT;\n\n const {\n children,\n title,\n secondaryTitle,\n customActions,\n iconOpened: IconOpened,\n iconClosed: IconClosed,\n value,\n disabled,\n dsIndex,\n renderCustomActions,\n } = propsWithDefaults;\n\n const { handleOnClick, handleOnKeyDown, selected } = useAccordionItem({ value, disabled });\n const {\n allChildrenReferences,\n actualActiveValue,\n props: { isDSMobile },\n } = useContext(DSAccordionContext);\n\n const onKeyDownWithIndex = useCallback(\n (e: React.KeyboardEvent) => {\n handleOnKeyDown(e, dsIndex);\n },\n [dsIndex, handleOnKeyDown],\n );\n\n const [showPopover, setShowPopover] = useState(false);\n const [referenceElement, setReferenceElement] = useState();\n\n const CustomActionsContent = useMemo(() => {\n if (!isDSMobile && customActions?.length > 0)\n return (\n <StyledItemCustomActions>\n {customActions?.map(({ onClick, id, ...rest }) => (\n <DSButton\n key={id}\n onClick={(e: React.MouseEvent) => {\n e.stopPropagation();\n if (onClick) onClick(e);\n }}\n {...rest}\n buttonType={BUTTON_TYPE.SECONDARY}\n />\n ))}\n </StyledItemCustomActions>\n );\n\n if (!isDSMobile && renderCustomActions)\n return (\n <StyledItemCustomActions>\n {renderCustomActions({ allRefs: allChildrenReferences, actualActiveValue })}\n </StyledItemCustomActions>\n );\n return null;\n }, [actualActiveValue, allChildrenReferences, customActions, isDSMobile, renderCustomActions]);\n\n const { isShowingEllipsis: isPrimaryShowingEllipsis, setElement: setPrimaryElement } = useIsShowingEllipsis();\n\n const { isShowingEllipsis: isSecondaryShowingEllipsis, setElement: setSecondaryElement } = useIsShowingEllipsis();\n\n const handleOnFocus = useCallback(\n () => setShowPopover(isPrimaryShowingEllipsis || isSecondaryShowingEllipsis),\n [isPrimaryShowingEllipsis, isSecondaryShowingEllipsis],\n );\n\n const handleOnBlur = useCallback(() => setShowPopover(false), []);\n\n const Titles = useMemo(() => {\n if (isPrimaryShowingEllipsis || isSecondaryShowingEllipsis)\n return (\n <>\n <StyledPrimaryTitle\n ref={setPrimaryElement}\n id={`accordion_${title}id`}\n disabled={disabled}\n isDSMobile={isDSMobile}\n >\n {title}\n </StyledPrimaryTitle>\n {!isDSMobile && secondaryTitle && (\n <StyledSecondaryTitle ref={setSecondaryElement} disabled={disabled}>\n {secondaryTitle}\n </StyledSecondaryTitle>\n )}\n <DSPopperJS referenceElement={referenceElement} showPopover={showPopover}>\n <div style={{ maxWidth: 260, padding: 8, background: 'white', display: 'grid', gap: 8 }}>\n <p style={{ margin: 0 }}>{title}</p>\n <p style={{ margin: 0 }}> {secondaryTitle}</p>\n </div>\n </DSPopperJS>\n </>\n );\n\n return (\n <>\n <StyledPrimaryTitle\n ref={setPrimaryElement}\n id={`accordion_${title}id`}\n disabled={disabled}\n isDSMobile={isDSMobile}\n >\n {title}\n </StyledPrimaryTitle>\n {!isDSMobile && secondaryTitle && (\n <StyledSecondaryTitle ref={setSecondaryElement} disabled={disabled}>\n {secondaryTitle}\n </StyledSecondaryTitle>\n )}\n </>\n );\n }, [\n disabled,\n isDSMobile,\n isPrimaryShowingEllipsis,\n isSecondaryShowingEllipsis,\n referenceElement,\n secondaryTitle,\n setPrimaryElement,\n setSecondaryElement,\n showPopover,\n title,\n ]);\n\n return (\n <StyledItemContainer data-testid={DSAccordionDataTestid.ITEM.CONTAINER}>\n <StyledItemHeaderContainer disabled={disabled}>\n <StyledItemHeader\n withCustomActions={(customActions?.length > 0 || renderCustomActions !== undefined) && !isDSMobile}\n withSecondaryTitle={secondaryTitle}\n onClick={handleOnClick}\n tabIndex={!disabled ? 0 : undefined}\n disabled={disabled}\n data-disabled={disabled}\n ref={allChildrenReferences[dsIndex]}\n onKeyDown={onKeyDownWithIndex}\n isDSMobile={isDSMobile}\n data-testid={DSAccordionDataTestid.ITEM.HEADER}\n id={`ds-accordion-header-${value}`}\n aria-expanded={selected}\n aria-disabled={disabled}\n aria-controls={`ds-accordion-content-${value}`}\n onFocus={handleOnFocus}\n onBlur={handleOnBlur}\n >\n <StyledItemAddon disabled={disabled} isDSMobile={isDSMobile}>\n {selected ? <IconOpened isDSMobile={isDSMobile} /> : <IconClosed isDSMobile={isDSMobile} />}\n </StyledItemAddon>\n <StyledItemTitles\n onMouseEnter={handleOnFocus}\n onMouseLeave={handleOnBlur}\n isDSMobile={isDSMobile}\n ref={setReferenceElement}\n >\n {Titles}\n </StyledItemTitles>\n </StyledItemHeader>\n {CustomActionsContent}\n </StyledItemHeaderContainer>\n {selected && (\n <StyledItemContent\n data-testid={DSAccordionDataTestid.ITEM.CONTENT}\n aria-labelledby={`ds-accordion-header-${value}`}\n role=\"region\"\n isDSMobile={isDSMobile}\n id={`ds-accordion-content-${value}`}\n >\n {children}\n </StyledItemContent>\n )}\n </StyledItemContainer>\n );\n};\n\nDSAccordionItem.propTypes = accordionItemPropTypes;\n\nconst DSAccordionItemWithSchema = describe(DSAccordionItem);\nDSAccordionItemWithSchema.propTypes = accordionItemPropTypes;\n\nexport { DSAccordionItem, DSAccordionItemWithSchema };\nexport default DSAccordionItem;\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -1,133 +1,114 @@
1
- import styled from 'styled-components';
1
+ import * as React from "react";
2
+ import styled from "styled-components";
3
+ const StyledItemContainer = styled.div`
4
+ display: grid;
5
+ grid-template-rows: auto auto;
6
+ border-bottom: 1px solid ${({ theme }) => theme.colors.neutral[200]};
7
+ align-items: center;
8
+ `;
9
+ const StyledItemHeader = styled.button`
10
+ display: flex;
11
+ height: ${({ theme, withSecondaryTitle }) => withSecondaryTitle ? theme.space.m : theme.space.s};
12
+ width: 100%;
13
+ align-items: center;
14
+ border: none;
15
+ outline: none;
16
+ background: none;
2
17
 
3
- const StyledItemContainer = /*#__PURE__*/styled.div.withConfig({
4
- componentId: "sc-fnpjby-0"
5
- })(["display:grid;grid-template-rows:auto auto;border-bottom:1px solid ", ";align-items:center;"], _ref => {
6
- let {
7
- theme
8
- } = _ref;
9
- return theme.colors.neutral[200];
10
- });
11
- const StyledItemHeader = /*#__PURE__*/styled.button.withConfig({
12
- componentId: "sc-fnpjby-1"
13
- })(["display:flex;height:", ";width:100%;align-items:center;border:none;outline:none;background:none;&:hover{cursor:", ";}padding:", ";", " &:focus{&:after{position:absolute;content:'';left:0;top:0;width:100%;height:100%;border-radius:2px;border:2px solid ", ";pointer-events:none;}}"], _ref2 => {
14
- let {
15
- theme,
16
- withSecondaryTitle
17
- } = _ref2;
18
- return withSecondaryTitle ? theme.space.m : theme.space.s;
19
- }, _ref3 => {
20
- let {
21
- disabled
22
- } = _ref3;
23
- return disabled ? 'not-allowed' : 'pointer';
24
- }, _ref4 => {
25
- let {
26
- isDSMobile
27
- } = _ref4;
28
- return isDSMobile ? "0 16px" : "0";
29
- }, _ref5 => {
30
- let {
31
- isDSMobile
32
- } = _ref5;
33
- return isDSMobile ? "flex-direction: row-reverse;" : "";
34
- }, _ref6 => {
35
- let {
36
- theme
37
- } = _ref6;
38
- return theme.colors.brand[700];
39
- });
40
- const StyledItemContent = /*#__PURE__*/styled.div.withConfig({
41
- componentId: "sc-fnpjby-2"
42
- })(["margin:", ";grid-column:1/2;"], _ref7 => {
43
- let {
44
- isDSMobile
45
- } = _ref7;
46
- return isDSMobile ? "16px 16px 24px 16px" : "16px 16px 16px 32px";
47
- });
48
- const StyledItemAddon = /*#__PURE__*/styled.div.withConfig({
49
- componentId: "sc-fnpjby-3"
50
- })(["", " height:100%;width:", ";display:grid;place-items:center;& .em-ds-icon svg{fill:", ";}"], _ref8 => {
51
- let {
52
- theme,
53
- isDSMobile
54
- } = _ref8;
55
- return !isDSMobile ? "padding: 0 ".concat(theme.space.xxs, ";") : "";
56
- }, _ref9 => {
57
- let {
58
- theme
59
- } = _ref9;
60
- return theme.space.s;
61
- }, _ref10 => {
62
- let {
63
- disabled,
64
- theme
65
- } = _ref10;
66
- return disabled ? theme.colors.neutral[200] : theme.colors.brand[800];
67
- });
68
- const StyledItemTitles = /*#__PURE__*/styled.div.withConfig({
69
- componentId: "sc-fnpjby-4"
70
- })(["display:grid;grid-template-columns:100%;width:100%;align-content:center;"]);
71
- const StyledPrimaryTitle = /*#__PURE__*/styled.div.withConfig({
72
- componentId: "sc-fnpjby-5"
73
- })(["margin:0;font-size:16px;color:", ";font-weight:", ";text-overflow:ellipsis;overflow:hidden;height:", ";width:100%;text-align:left;display:block;white-space:nowrap;"], _ref11 => {
74
- let {
75
- disabled,
76
- theme
77
- } = _ref11;
78
- return disabled ? theme.colors.neutral[200] : theme.colors.neutral[700];
79
- }, _ref12 => {
80
- let {
81
- theme,
82
- isDSMobile
83
- } = _ref12;
84
- return isDSMobile ? theme.fontWeights.regular : theme.fontWeights.regular;
85
- }, _ref13 => {
86
- let {
87
- theme
88
- } = _ref13;
89
- return theme.space.xs;
90
- });
91
- const StyledSecondaryTitle = /*#__PURE__*/styled.span.withConfig({
92
- componentId: "sc-fnpjby-6"
93
- })(["margin:0;font-size:", ";text-align:left;color:", ";text-overflow:ellipsis;overflow:hidden;height:", ";width:100%;text-align:left;display:block;white-space:nowrap;"], _ref14 => {
94
- let {
95
- theme
96
- } = _ref14;
97
- return theme.fontSizes.label[200];
98
- }, _ref15 => {
99
- let {
100
- disabled,
101
- theme
102
- } = _ref15;
103
- return disabled ? theme.colors.neutral[200] : theme.colors.neutral[500];
104
- }, _ref16 => {
105
- let {
106
- theme
107
- } = _ref16;
108
- return theme.space.xs;
109
- });
110
- const StyledItemCustomActions = /*#__PURE__*/styled.div.withConfig({
111
- componentId: "sc-fnpjby-7"
112
- })(["display:grid;grid-auto-flow:column;grid-gap:", ";margin:0 ", ";justify-content:flex-end;"], _ref17 => {
113
- let {
114
- theme
115
- } = _ref17;
116
- return theme.space.xxs;
117
- }, _ref18 => {
118
- let {
119
- theme
120
- } = _ref18;
121
- return theme.space.xs;
122
- });
123
- const StyledItemHeaderContainer = /*#__PURE__*/styled.div.withConfig({
124
- componentId: "sc-fnpjby-8"
125
- })(["display:grid;grid-template-columns:auto max-content;place-items:center;position:relative;&:hover{", "}"], _ref19 => {
126
- let {
127
- disabled,
128
- theme
129
- } = _ref19;
130
- return !disabled ? "background: ".concat(theme.colors.brand[200], ";") : "";
131
- });
18
+ &:hover {
19
+ cursor: ${({ disabled }) => disabled ? "not-allowed" : "pointer"};
20
+ }
132
21
 
133
- export { StyledItemAddon, StyledItemContainer, StyledItemContent, StyledItemCustomActions, StyledItemHeader, StyledItemHeaderContainer, StyledItemTitles, StyledPrimaryTitle, StyledSecondaryTitle };
22
+ padding: ${({ isDSMobile }) => isDSMobile ? `0 16px` : `0`};
23
+
24
+ ${({ isDSMobile }) => isDSMobile ? `flex-direction: row-reverse;` : ``}
25
+
26
+ &:focus {
27
+ &:after {
28
+ position: absolute;
29
+ content: '';
30
+ left: 0;
31
+ top: 0;
32
+ width: 100%;
33
+ height: 100%;
34
+ border-radius: 2px;
35
+ border: 2px solid ${({ theme }) => theme.colors.brand[700]};
36
+ pointer-events: none;
37
+ }
38
+ }
39
+ `;
40
+ const StyledItemContent = styled.div`
41
+ margin: ${({ isDSMobile }) => isDSMobile ? `16px 16px 24px 16px` : `16px 16px 16px 32px`};
42
+ grid-column: 1/2;
43
+ `;
44
+ const StyledItemAddon = styled.div`
45
+ ${({ theme, isDSMobile }) => !isDSMobile ? `padding: 0 ${theme.space.xxs};` : ``}
46
+ height: 100%;
47
+ width: ${({ theme }) => theme.space.s};
48
+ display: grid;
49
+ place-items: center;
50
+
51
+ & .em-ds-icon svg {
52
+ fill: ${({ disabled, theme }) => disabled ? theme.colors.neutral[200] : theme.colors.brand[800]};
53
+ }
54
+ `;
55
+ const StyledItemTitles = styled.div`
56
+ display: grid;
57
+ grid-template-columns: 100%;
58
+ width: 100%;
59
+ align-content: center;
60
+ `;
61
+ const StyledPrimaryTitle = styled.div`
62
+ margin: 0;
63
+ font-size: 16px;
64
+ color: ${({ disabled, theme }) => disabled ? theme.colors.neutral[200] : theme.colors.neutral[700]};
65
+ font-weight: ${({ theme, isDSMobile }) => isDSMobile ? theme.fontWeights.regular : theme.fontWeights.regular};
66
+ text-overflow: ellipsis;
67
+ overflow: hidden;
68
+ height: ${({ theme }) => theme.space.xs};
69
+ width: 100%;
70
+ text-align: left;
71
+ display: block;
72
+ white-space: nowrap;
73
+ `;
74
+ const StyledSecondaryTitle = styled.span`
75
+ margin: 0;
76
+ font-size: ${({ theme }) => theme.fontSizes.label[200]};
77
+ text-align: left;
78
+ color: ${({ disabled, theme }) => disabled ? theme.colors.neutral[200] : theme.colors.neutral[500]};
79
+ text-overflow: ellipsis;
80
+ overflow: hidden;
81
+ height: ${({ theme }) => theme.space.xs};
82
+ width: 100%;
83
+ text-align: left;
84
+ display: block;
85
+ white-space: nowrap;
86
+ `;
87
+ const StyledItemCustomActions = styled.div`
88
+ display: grid;
89
+ grid-auto-flow: column;
90
+ grid-gap: ${({ theme }) => theme.space.xxs};
91
+ margin: 0 ${({ theme }) => theme.space.xs};
92
+ justify-content: flex-end;
93
+ `;
94
+ const StyledItemHeaderContainer = styled.div`
95
+ display: grid;
96
+ grid-template-columns: auto max-content;
97
+ place-items: center;
98
+ position: relative;
99
+ &:hover {
100
+ ${({ disabled, theme }) => !disabled ? `background: ${theme.colors.brand[200]};` : ``}
101
+ }
102
+ `;
103
+ export {
104
+ StyledItemAddon,
105
+ StyledItemContainer,
106
+ StyledItemContent,
107
+ StyledItemCustomActions,
108
+ StyledItemHeader,
109
+ StyledItemHeaderContainer,
110
+ StyledItemTitles,
111
+ StyledPrimaryTitle,
112
+ StyledSecondaryTitle
113
+ };
114
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/accordionItem/styles.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\nimport type {\n StyledItemAddonPropsT,\n StyledItemHeaderPropsT,\n StyledItemTitlesPropsT,\n StyledPrimaryTitlePropsT,\n StyledSecondaryTitlePropsT,\n StyledItemContentPropsT,\n StyledItemHeaderContainerPropsT,\n} from '../../DSAccordionTypes';\n\nexport const StyledItemContainer = styled.div`\n display: grid;\n grid-template-rows: auto auto;\n border-bottom: 1px solid ${({ theme }) => theme.colors.neutral[200]};\n align-items: center;\n`;\n\nexport const StyledItemHeader = styled.button<StyledItemHeaderPropsT>`\n display: flex;\n height: ${({ theme, withSecondaryTitle }) => (withSecondaryTitle ? theme.space.m : theme.space.s)};\n width: 100%;\n align-items: center;\n border: none;\n outline: none;\n background: none;\n\n &:hover {\n cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};\n }\n\n padding: ${({ isDSMobile }) => (isDSMobile ? `0 16px` : `0`)};\n\n ${({ isDSMobile }) => (isDSMobile ? `flex-direction: row-reverse;` : ``)}\n\n &:focus {\n &:after {\n position: absolute;\n content: '';\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n border-radius: 2px;\n border: 2px solid ${({ theme }) => theme.colors.brand[700]};\n pointer-events: none;\n }\n }\n`;\n\nexport const StyledItemContent = styled.div<StyledItemContentPropsT>`\n margin: ${({ isDSMobile }) => (isDSMobile ? `16px 16px 24px 16px` : `16px 16px 16px 32px`)};\n grid-column: 1/2;\n`;\n\nexport const StyledItemAddon = styled.div<StyledItemAddonPropsT>`\n ${({ theme, isDSMobile }) => (!isDSMobile ? `padding: 0 ${theme.space.xxs};` : ``)}\n height: 100%;\n width: ${({ theme }) => theme.space.s};\n display: grid;\n place-items: center;\n\n & .em-ds-icon svg {\n fill: ${({ disabled, theme }) => (disabled ? theme.colors.neutral[200] : theme.colors.brand[800])};\n }\n`;\n\nexport const StyledItemTitles = styled.div<StyledItemTitlesPropsT>`\n display: grid;\n grid-template-columns: 100%;\n width: 100%;\n align-content: center;\n`;\n\nexport const StyledPrimaryTitle = styled.div<StyledPrimaryTitlePropsT>`\n margin: 0;\n font-size: 16px;\n color: ${({ disabled, theme }) => (disabled ? theme.colors.neutral[200] : theme.colors.neutral[700])};\n font-weight: ${({ theme, isDSMobile }) => (isDSMobile ? theme.fontWeights.regular : theme.fontWeights.regular)};\n text-overflow: ellipsis;\n overflow: hidden;\n height: ${({ theme }) => theme.space.xs};\n width: 100%;\n text-align: left;\n display: block;\n white-space: nowrap;\n`;\n\nexport const StyledSecondaryTitle = styled.span<StyledSecondaryTitlePropsT>`\n margin: 0;\n font-size: ${({ theme }) => theme.fontSizes.label[200]};\n text-align: left;\n color: ${({ disabled, theme }) => (disabled ? theme.colors.neutral[200] : theme.colors.neutral[500])};\n text-overflow: ellipsis;\n overflow: hidden;\n height: ${({ theme }) => theme.space.xs};\n width: 100%;\n text-align: left;\n display: block;\n white-space: nowrap;\n`;\n\nexport const StyledItemCustomActions = styled.div`\n display: grid;\n grid-auto-flow: column;\n grid-gap: ${({ theme }) => theme.space.xxs};\n margin: 0 ${({ theme }) => theme.space.xs};\n justify-content: flex-end;\n`;\n\nexport const StyledItemHeaderContainer = styled.div<StyledItemHeaderContainerPropsT>`\n display: grid;\n grid-template-columns: auto max-content;\n place-items: center;\n position: relative;\n &:hover {\n ${({ disabled, theme }) => (!disabled ? `background: ${theme.colors.brand[200]};` : ``)}\n }\n`;\n"],
5
+ "mappings": "AAAA;ACAA;AAWO,MAAM,sBAAsB,OAAO;AAAA;AAAA;AAAA,6BAGb,CAAC,EAAE,YAAY,MAAM,OAAO,QAAQ;AAAA;AAAA;AAI1D,MAAM,mBAAmB,OAAO;AAAA;AAAA,YAE3B,CAAC,EAAE,OAAO,yBAA0B,qBAAqB,MAAM,MAAM,IAAI,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAQnF,CAAC,EAAE,eAAgB,WAAW,gBAAgB;AAAA;AAAA;AAAA,aAG/C,CAAC,EAAE,iBAAkB,aAAa,WAAW;AAAA;AAAA,IAEtD,CAAC,EAAE,iBAAkB,aAAa,iCAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAW7C,CAAC,EAAE,YAAY,MAAM,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAMrD,MAAM,oBAAoB,OAAO;AAAA,YAC5B,CAAC,EAAE,iBAAkB,aAAa,wBAAwB;AAAA;AAAA;AAI/D,MAAM,kBAAkB,OAAO;AAAA,IAClC,CAAC,EAAE,OAAO,iBAAkB,CAAC,aAAa,cAAc,MAAM,MAAM,SAAS;AAAA;AAAA,WAEtE,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,YAK1B,CAAC,EAAE,UAAU,YAAa,WAAW,MAAM,OAAO,QAAQ,OAAO,MAAM,OAAO,MAAM;AAAA;AAAA;AAIzF,MAAM,mBAAmB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOhC,MAAM,qBAAqB,OAAO;AAAA;AAAA;AAAA,WAG9B,CAAC,EAAE,UAAU,YAAa,WAAW,MAAM,OAAO,QAAQ,OAAO,MAAM,OAAO,QAAQ;AAAA,iBAChF,CAAC,EAAE,OAAO,iBAAkB,aAAa,MAAM,YAAY,UAAU,MAAM,YAAY;AAAA;AAAA;AAAA,YAG5F,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAOhC,MAAM,uBAAuB,OAAO;AAAA;AAAA,eAE5B,CAAC,EAAE,YAAY,MAAM,UAAU,MAAM;AAAA;AAAA,WAEzC,CAAC,EAAE,UAAU,YAAa,WAAW,MAAM,OAAO,QAAQ,OAAO,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA,YAGrF,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAOhC,MAAM,0BAA0B,OAAO;AAAA;AAAA;AAAA,cAGhC,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA,cAC3B,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA;AAAA;AAIlC,MAAM,4BAA4B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAM1C,CAAC,EAAE,UAAU,YAAa,CAAC,WAAW,eAAe,MAAM,OAAO,MAAM,UAAU;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,42 +1,28 @@
1
- import 'core-js/modules/esnext.async-iterator.some.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.some.js';
4
- import { useContext, useMemo, useCallback } from 'react';
5
- import { DSAccordionContext } from '../../DSAccordionCTX.js';
6
-
7
- const useAccordionItem = _ref => {
8
- let {
9
- value,
10
- disabled
11
- } = _ref;
12
- const {
13
- actualActiveValue,
14
- setActiveValues,
15
- focusableChildrenReferences
16
- } = useContext(DSAccordionContext);
1
+ import * as React from "react";
2
+ import { useCallback, useContext, useMemo } from "react";
3
+ import { DSAccordionContext } from "../../DSAccordionCTX";
4
+ const useAccordionItem = ({ value, disabled }) => {
5
+ const { actualActiveValue, setActiveValues, focusableChildrenReferences } = useContext(DSAccordionContext);
17
6
  const selected = useMemo(() => {
18
7
  if (Array.isArray(actualActiveValue)) {
19
- return actualActiveValue.some(currentValue => currentValue === value);
8
+ return actualActiveValue.some((currentValue) => currentValue === value);
20
9
  }
21
-
22
10
  return value === actualActiveValue;
23
11
  }, [actualActiveValue, value]);
24
- const handleOnClick = useCallback(e => {
25
- if (!disabled) setActiveValues(value, e);
12
+ const handleOnClick = useCallback((e) => {
13
+ if (!disabled)
14
+ setActiveValues(value, e);
26
15
  }, [disabled, setActiveValues, value]);
27
16
  const handleOnKeyDown = useCallback((e, _dsIndex) => {
28
- if (!disabled && e.key === 'ArrowDown') {
29
- var _focusableChildrenRef, _focusableChildrenRef2, _focusableChildrenRef3, _focusableChildrenRef4, _focusableChildrenRef5;
30
-
31
- const currentIndex = focusableChildrenReferences.findIndex(item => item.index === _dsIndex);
32
- if ((_focusableChildrenRef = focusableChildrenReferences[currentIndex + 1]) !== null && _focusableChildrenRef !== void 0 && (_focusableChildrenRef2 = _focusableChildrenRef.ref) !== null && _focusableChildrenRef2 !== void 0 && _focusableChildrenRef2.current) (_focusableChildrenRef3 = focusableChildrenReferences[currentIndex + 1]) === null || _focusableChildrenRef3 === void 0 ? void 0 : (_focusableChildrenRef4 = _focusableChildrenRef3.ref) === null || _focusableChildrenRef4 === void 0 ? void 0 : (_focusableChildrenRef5 = _focusableChildrenRef4.current) === null || _focusableChildrenRef5 === void 0 ? void 0 : _focusableChildrenRef5.focus();
17
+ if (!disabled && e.key === "ArrowDown") {
18
+ const currentIndex = focusableChildrenReferences.findIndex((item) => item.index === _dsIndex);
19
+ if (focusableChildrenReferences[currentIndex + 1]?.ref?.current)
20
+ focusableChildrenReferences[currentIndex + 1]?.ref?.current?.focus();
33
21
  }
34
-
35
- if (!disabled && e.key === 'ArrowUp') {
36
- var _focusableChildrenRef6, _focusableChildrenRef7, _focusableChildrenRef8, _focusableChildrenRef9, _focusableChildrenRef10;
37
-
38
- const currentIndex = focusableChildrenReferences.findIndex(item => item.index === _dsIndex);
39
- if ((_focusableChildrenRef6 = focusableChildrenReferences[currentIndex - 1]) !== null && _focusableChildrenRef6 !== void 0 && (_focusableChildrenRef7 = _focusableChildrenRef6.ref) !== null && _focusableChildrenRef7 !== void 0 && _focusableChildrenRef7.current) (_focusableChildrenRef8 = focusableChildrenReferences[currentIndex - 1]) === null || _focusableChildrenRef8 === void 0 ? void 0 : (_focusableChildrenRef9 = _focusableChildrenRef8.ref) === null || _focusableChildrenRef9 === void 0 ? void 0 : (_focusableChildrenRef10 = _focusableChildrenRef9.current) === null || _focusableChildrenRef10 === void 0 ? void 0 : _focusableChildrenRef10.focus();
22
+ if (!disabled && e.key === "ArrowUp") {
23
+ const currentIndex = focusableChildrenReferences.findIndex((item) => item.index === _dsIndex);
24
+ if (focusableChildrenReferences[currentIndex - 1]?.ref?.current)
25
+ focusableChildrenReferences[currentIndex - 1]?.ref?.current?.focus();
40
26
  }
41
27
  }, [disabled, focusableChildrenReferences]);
42
28
  return {
@@ -45,5 +31,7 @@ const useAccordionItem = _ref => {
45
31
  selected
46
32
  };
47
33
  };
48
-
49
- export { useAccordionItem };
34
+ export {
35
+ useAccordionItem
36
+ };
37
+ //# sourceMappingURL=useAccordionItem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/accordionItem/useAccordionItem.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useContext, useMemo } from 'react';\nimport { DSAccordionContext } from '../../DSAccordionCTX';\nimport type { UseAccordionPropsT, UseAccordionItemReturnTypeT } from '../../DSAccordionTypes';\n\nexport const useAccordionItem = ({ value, disabled }: UseAccordionPropsT): UseAccordionItemReturnTypeT => {\n const { actualActiveValue, setActiveValues, focusableChildrenReferences } = useContext(DSAccordionContext);\n\n const selected = useMemo(() => {\n if (Array.isArray(actualActiveValue)) {\n return actualActiveValue.some((currentValue) => currentValue === value);\n }\n return value === actualActiveValue;\n }, [actualActiveValue, value]);\n\n const handleOnClick = useCallback(\n (e: React.MouseEvent) => {\n if (!disabled) setActiveValues(value, e);\n },\n [disabled, setActiveValues, value],\n );\n\n const handleOnKeyDown = useCallback(\n (e: React.KeyboardEvent, _dsIndex: number) => {\n if (!disabled && e.key === 'ArrowDown') {\n const currentIndex = focusableChildrenReferences.findIndex((item) => item.index === _dsIndex);\n if (focusableChildrenReferences[currentIndex + 1]?.ref?.current)\n focusableChildrenReferences[currentIndex + 1]?.ref?.current?.focus();\n }\n\n if (!disabled && e.key === 'ArrowUp') {\n const currentIndex = focusableChildrenReferences.findIndex((item) => item.index === _dsIndex);\n if (focusableChildrenReferences[currentIndex - 1]?.ref?.current)\n focusableChildrenReferences[currentIndex - 1]?.ref?.current?.focus();\n }\n },\n [disabled, focusableChildrenReferences],\n );\n\n return {\n handleOnClick,\n handleOnKeyDown,\n selected,\n };\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAGO,MAAM,mBAAmB,CAAC,EAAE,OAAO,eAAgE;AACxG,QAAM,EAAE,mBAAmB,iBAAiB,gCAAgC,WAAW;AAEvF,QAAM,WAAW,QAAQ,MAAM;AAC7B,QAAI,MAAM,QAAQ,oBAAoB;AACpC,aAAO,kBAAkB,KAAK,CAAC,iBAAiB,iBAAiB;AAAA;AAEnE,WAAO,UAAU;AAAA,KAChB,CAAC,mBAAmB;AAEvB,QAAM,gBAAgB,YACpB,CAAC,MAAwB;AACvB,QAAI,CAAC;AAAU,sBAAgB,OAAO;AAAA,KAExC,CAAC,UAAU,iBAAiB;AAG9B,QAAM,kBAAkB,YACtB,CAAC,GAAwB,aAAqB;AAC5C,QAAI,CAAC,YAAY,EAAE,QAAQ,aAAa;AACtC,YAAM,eAAe,4BAA4B,UAAU,CAAC,SAAS,KAAK,UAAU;AACpF,UAAI,4BAA4B,eAAe,IAAI,KAAK;AACtD,oCAA4B,eAAe,IAAI,KAAK,SAAS;AAAA;AAGjE,QAAI,CAAC,YAAY,EAAE,QAAQ,WAAW;AACpC,YAAM,eAAe,4BAA4B,UAAU,CAAC,SAAS,KAAK,UAAU;AACpF,UAAI,4BAA4B,eAAe,IAAI,KAAK;AACtD,oCAA4B,eAAe,IAAI,KAAK,SAAS;AAAA;AAAA,KAGnE,CAAC,UAAU;AAGb,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/esm/propTypes.js CHANGED
@@ -1,21 +1,28 @@
1
- import { PropTypes } from 'react-desc';
2
-
1
+ import * as React from "react";
2
+ import { PropTypes } from "react-desc";
3
3
  const accordionItemPropTypes = {
4
- children: PropTypes.node.description('Dimsum AccordionItem content.').isRequired,
5
- title: PropTypes.string.description('Set a primary title.'),
6
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Dimsum AccordionItem value, this value should be unique.').isRequired,
7
- iconClosed: PropTypes.node.description('Custom Dimsum Icon when it is closed.'),
8
- iconOpened: PropTypes.node.description('Custom Dimsum Icon when it is open.'),
9
- secondaryTitle: PropTypes.string.description('Set a secondary title'),
10
- customActions: PropTypes.arrayOf(PropTypes.object).description('Set Dimsum AccordionItem custom actions.'),
11
- renderCustomActions: PropTypes.func.description('This property will render any JSX in the custom actions area. You can access to all references and active values within the props.')
4
+ children: PropTypes.node.description("Dimsum AccordionItem content.").isRequired,
5
+ title: PropTypes.string.description("Set a primary title."),
6
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description("Dimsum AccordionItem value, this value should be unique.").isRequired,
7
+ iconClosed: PropTypes.node.description("Custom Dimsum Icon when it is closed."),
8
+ iconOpened: PropTypes.node.description("Custom Dimsum Icon when it is open."),
9
+ secondaryTitle: PropTypes.string.description("Set a secondary title"),
10
+ customActions: PropTypes.arrayOf(PropTypes.object).description("Set Dimsum AccordionItem custom actions."),
11
+ renderCustomActions: PropTypes.func.description("This property will render any JSX in the custom actions area. You can access to all references and active values within the props.")
12
12
  };
13
13
  const accordionPropTypes = {
14
- containerProps: PropTypes.object.description('Adds props to the container.'),
15
- activeValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), PropTypes.string, PropTypes.number]).description('Selected active value. This property makes the component a controlled one.'),
16
- children: PropTypes.node.description('Dimsum AccordionItems to show.'),
17
- allowMultipleOpen: PropTypes.bool.description('Allows multiple Dimsum AccordionItems to be open at the same time.'),
18
- onChange: PropTypes.func.description('Callback function once the Dimsum Accordion changes.')
14
+ containerProps: PropTypes.object.description("Adds props to the container."),
15
+ activeValue: PropTypes.oneOfType([
16
+ PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
17
+ PropTypes.string,
18
+ PropTypes.number
19
+ ]).description("Selected active value. This property makes the component a controlled one."),
20
+ children: PropTypes.node.description("Dimsum AccordionItems to show."),
21
+ allowMultipleOpen: PropTypes.bool.description("Allows multiple Dimsum AccordionItems to be open at the same time."),
22
+ onChange: PropTypes.func.description("Callback function once the Dimsum Accordion changes.")
19
23
  };
20
-
21
- export { accordionItemPropTypes, accordionPropTypes };
24
+ export {
25
+ accordionItemPropTypes,
26
+ accordionPropTypes
27
+ };
28
+ //# sourceMappingURL=propTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/propTypes.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\n\nexport const accordionItemPropTypes = {\n children: PropTypes.node.description('Dimsum AccordionItem content.').isRequired,\n title: PropTypes.string.description('Set a primary title.'),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Dimsum AccordionItem value, this value should be unique.',\n ).isRequired,\n iconClosed: PropTypes.node.description('Custom Dimsum Icon when it is closed.'),\n iconOpened: PropTypes.node.description('Custom Dimsum Icon when it is open.'),\n secondaryTitle: PropTypes.string.description('Set a secondary title'),\n customActions: PropTypes.arrayOf(PropTypes.object).description('Set Dimsum AccordionItem custom actions.'),\n renderCustomActions: PropTypes.func.description(\n 'This property will render any JSX in the custom actions area. You can access to all references and active values within the props.',\n ),\n};\n\nexport const accordionPropTypes = {\n containerProps: PropTypes.object.description('Adds props to the container.'),\n activeValue: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),\n PropTypes.string,\n PropTypes.number,\n ]).description('Selected active value. This property makes the component a controlled one.'),\n children: PropTypes.node.description('Dimsum AccordionItems to show.'),\n allowMultipleOpen: PropTypes.bool.description('Allows multiple Dimsum AccordionItems to be open at the same time.'),\n onChange: PropTypes.func.description('Callback function once the Dimsum Accordion changes.'),\n};\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,yBAAyB;AAAA,EACpC,UAAU,UAAU,KAAK,YAAY,iCAAiC;AAAA,EACtE,OAAO,UAAU,OAAO,YAAY;AAAA,EACpC,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAC/D,4DACA;AAAA,EACF,YAAY,UAAU,KAAK,YAAY;AAAA,EACvC,YAAY,UAAU,KAAK,YAAY;AAAA,EACvC,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAC7C,eAAe,UAAU,QAAQ,UAAU,QAAQ,YAAY;AAAA,EAC/D,qBAAqB,UAAU,KAAK,YAClC;AAAA;AAIG,MAAM,qBAAqB;AAAA,EAChC,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAC7C,aAAa,UAAU,UAAU;AAAA,IAC/B,UAAU,QAAQ,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU;AAAA,IACnE,UAAU;AAAA,IACV,UAAU;AAAA,KACT,YAAY;AAAA,EACf,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,mBAAmB,UAAU,KAAK,YAAY;AAAA,EAC9C,UAAU,UAAU,KAAK,YAAY;AAAA;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-accordion",
3
- "version": "2.2.1",
3
+ "version": "2.3.0-alpha.4",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Accordion",
6
6
  "module": "./esm/index.js",
@@ -15,10 +15,6 @@
15
15
  "import": "./esm/propTypes.js",
16
16
  "require": "./cjs/propTypes.js"
17
17
  },
18
- "./parts/accordionItem/useIsShowingEllipsis": {
19
- "import": "./esm/parts/accordionItem/useIsShowingEllipsis.js",
20
- "require": "./cjs/parts/accordionItem/useIsShowingEllipsis.js"
21
- },
22
18
  "./parts/accordionItem/useAccordionItem": {
23
19
  "import": "./esm/parts/accordionItem/useAccordionItem.js",
24
20
  "require": "./cjs/parts/accordionItem/useAccordionItem.js"
@@ -84,12 +80,12 @@
84
80
  "build": "node ../../scripts/build/build.js"
85
81
  },
86
82
  "dependencies": {
87
- "@elliemae/ds-button": "2.2.1",
88
- "@elliemae/ds-classnames": "2.2.1",
89
- "@elliemae/ds-icons": "2.2.1",
90
- "@elliemae/ds-shared": "2.2.1",
91
- "@elliemae/ds-system": "2.2.1",
92
- "@elliemae/ds-truncated-tooltip-text": "2.2.1",
83
+ "@elliemae/ds-button": "2.3.0-alpha.4",
84
+ "@elliemae/ds-classnames": "2.3.0-alpha.4",
85
+ "@elliemae/ds-icons": "2.3.0-alpha.4",
86
+ "@elliemae/ds-shared": "2.3.0-alpha.4",
87
+ "@elliemae/ds-system": "2.3.0-alpha.4",
88
+ "@elliemae/ds-truncated-tooltip-text": "2.3.0-alpha.4",
93
89
  "react-desc": "^4.1.3"
94
90
  },
95
91
  "devDependencies": {
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/web.dom-collections.iterator.js');
6
- var React = require('react');
7
-
8
- const useIsShowingEllipsis = () => {
9
- const [element, setElement] = React.useState();
10
- const [isShowingEllipsis, setIsShowingEllipsis] = React.useState(false); // const isShowingEllipsis = element?.scrollWidth > primaryTitleWrapperEl?.clientWidth;
11
-
12
- const resizeObserver = React.useMemo(() => new ResizeObserver(entries => {
13
- if (entries.length) {
14
- const [textWrapperEntry] = entries;
15
- const el = textWrapperEntry.target;
16
- setIsShowingEllipsis((el === null || el === void 0 ? void 0 : el.scrollWidth) > (el === null || el === void 0 ? void 0 : el.clientWidth));
17
- }
18
- }), []);
19
- React.useEffect(() => {
20
- if (element) {
21
- setIsShowingEllipsis((element === null || element === void 0 ? void 0 : element.scrollWidth) > (element === null || element === void 0 ? void 0 : element.clientWidth));
22
- resizeObserver.observe(element);
23
- }
24
-
25
- return () => {
26
- if (element) {
27
- resizeObserver.unobserve(element);
28
- }
29
- };
30
- }, [resizeObserver, element]);
31
- return {
32
- setElement,
33
- isShowingEllipsis
34
- };
35
- };
36
-
37
- exports.useIsShowingEllipsis = useIsShowingEllipsis;
@@ -1,33 +0,0 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState, useMemo, useEffect } from 'react';
3
-
4
- const useIsShowingEllipsis = () => {
5
- const [element, setElement] = useState();
6
- const [isShowingEllipsis, setIsShowingEllipsis] = useState(false); // const isShowingEllipsis = element?.scrollWidth > primaryTitleWrapperEl?.clientWidth;
7
-
8
- const resizeObserver = useMemo(() => new ResizeObserver(entries => {
9
- if (entries.length) {
10
- const [textWrapperEntry] = entries;
11
- const el = textWrapperEntry.target;
12
- setIsShowingEllipsis((el === null || el === void 0 ? void 0 : el.scrollWidth) > (el === null || el === void 0 ? void 0 : el.clientWidth));
13
- }
14
- }), []);
15
- useEffect(() => {
16
- if (element) {
17
- setIsShowingEllipsis((element === null || element === void 0 ? void 0 : element.scrollWidth) > (element === null || element === void 0 ? void 0 : element.clientWidth));
18
- resizeObserver.observe(element);
19
- }
20
-
21
- return () => {
22
- if (element) {
23
- resizeObserver.unobserve(element);
24
- }
25
- };
26
- }, [resizeObserver, element]);
27
- return {
28
- setElement,
29
- isShowingEllipsis
30
- };
31
- };
32
-
33
- export { useIsShowingEllipsis };
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- export declare const useIsShowingEllipsis: () => {
3
- setElement: React.Dispatch<React.SetStateAction<HTMLSpanElement | undefined>>;
4
- isShowingEllipsis: boolean;
5
- };