@elliemae/ds-accordion 2.2.0-alpha.4 → 3.0.0-next.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/cjs/DSAccordion.js +29 -50
- package/cjs/DSAccordionCTX.js +14 -40
- package/cjs/DSAccordionDatatestid.js +10 -38
- package/cjs/DSAccordionTypes.js +2 -27
- package/cjs/config/useAccordion.js +36 -59
- package/cjs/config/useAccordionRefs.js +39 -46
- package/cjs/defaultProps.js +39 -49
- package/cjs/index.js +14 -37
- package/cjs/parts/accordionContent/AccordionContent.js +35 -44
- package/cjs/parts/accordionItem/DSAccordionItem.js +174 -147
- package/cjs/parts/accordionItem/styles.js +128 -142
- package/cjs/parts/accordionItem/useAccordionItem.js +39 -52
- package/cjs/parts/accordionItem/useIsShowingEllipsis.js +21 -42
- package/cjs/propTypes.js +22 -53
- package/esm/DSAccordion.js +16 -18
- package/esm/DSAccordionCTX.js +9 -10
- package/esm/DSAccordionDatatestid.js +6 -9
- package/esm/DSAccordionTypes.js +1 -2
- package/esm/config/useAccordion.js +27 -25
- package/esm/config/useAccordionRefs.js +31 -17
- package/esm/defaultProps.js +31 -21
- package/esm/index.js +2 -8
- package/esm/parts/accordionContent/AccordionContent.js +25 -14
- package/esm/parts/accordionItem/DSAccordionItem.js +147 -114
- package/esm/parts/accordionItem/styles.js +115 -116
- package/esm/parts/accordionItem/useAccordionItem.js +33 -21
- package/esm/parts/accordionItem/useIsShowingEllipsis.js +15 -11
- package/esm/propTypes.js +17 -24
- package/package.json +7 -7
- package/cjs/DSAccordion.js.map +0 -7
- package/cjs/DSAccordionCTX.js.map +0 -7
- package/cjs/DSAccordionDatatestid.js.map +0 -7
- package/cjs/DSAccordionTypes.js.map +0 -7
- package/cjs/config/useAccordion.js.map +0 -7
- package/cjs/config/useAccordionRefs.js.map +0 -7
- package/cjs/defaultProps.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/parts/accordionContent/AccordionContent.js.map +0 -7
- package/cjs/parts/accordionItem/DSAccordionItem.js.map +0 -7
- package/cjs/parts/accordionItem/styles.js.map +0 -7
- package/cjs/parts/accordionItem/useAccordionItem.js.map +0 -7
- package/cjs/parts/accordionItem/useIsShowingEllipsis.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/esm/DSAccordion.js.map +0 -7
- package/esm/DSAccordionCTX.js.map +0 -7
- package/esm/DSAccordionDatatestid.js.map +0 -7
- package/esm/DSAccordionTypes.js.map +0 -7
- package/esm/config/useAccordion.js.map +0 -7
- package/esm/config/useAccordionRefs.js.map +0 -7
- package/esm/defaultProps.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/parts/accordionContent/AccordionContent.js.map +0 -7
- package/esm/parts/accordionItem/DSAccordionItem.js.map +0 -7
- package/esm/parts/accordionItem/styles.js.map +0 -7
- package/esm/parts/accordionItem/useAccordionItem.js.map +0 -7
- package/esm/parts/accordionItem/useIsShowingEllipsis.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.some.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
7
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
8
|
+
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
9
|
+
import { useAccordionRefs } from './useAccordionRefs.js';
|
|
10
|
+
import { defaultProps } from '../defaultProps.js';
|
|
11
|
+
|
|
12
|
+
const useAccordion = props => {
|
|
7
13
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
8
|
-
const {
|
|
9
|
-
|
|
14
|
+
const {
|
|
15
|
+
activeValue,
|
|
16
|
+
allowMultipleOpen,
|
|
17
|
+
onChange
|
|
18
|
+
} = propsWithDefaults;
|
|
19
|
+
const {
|
|
20
|
+
focusableChildrenReferences,
|
|
21
|
+
allChildrenReferences
|
|
22
|
+
} = useAccordionRefs(propsWithDefaults);
|
|
10
23
|
const [internalActiveValue, setInternalActiveValue] = useState(activeValue);
|
|
11
24
|
const actualActiveValue = useMemo(() => {
|
|
12
|
-
if (activeValue ===
|
|
13
|
-
return internalActiveValue;
|
|
25
|
+
if (activeValue === undefined) return internalActiveValue;
|
|
14
26
|
return activeValue;
|
|
15
27
|
}, [activeValue, internalActiveValue]);
|
|
16
28
|
const setActiveValues = useCallback((value, e) => {
|
|
17
29
|
let newState;
|
|
18
|
-
if (allowMultipleOpen && (actualActiveValue ===
|
|
19
|
-
newState = [value];
|
|
20
|
-
else if (
|
|
21
|
-
if (!actualActiveValue.some((currentValues) => currentValues === value))
|
|
22
|
-
newState = [...actualActiveValue, value];
|
|
23
|
-
else
|
|
24
|
-
newState = actualActiveValue.filter((currentValues) => currentValues !== value);
|
|
25
|
-
else if (actualActiveValue === value)
|
|
26
|
-
newState = null;
|
|
27
|
-
else
|
|
28
|
-
newState = value;
|
|
30
|
+
if (allowMultipleOpen && (actualActiveValue === undefined || actualActiveValue === null)) newState = [value];else if (allowMultipleOpen && Array.isArray(actualActiveValue)) {
|
|
31
|
+
if (!actualActiveValue.some(currentValues => currentValues === value)) newState = [...actualActiveValue, value];else newState = actualActiveValue.filter(currentValues => currentValues !== value);
|
|
32
|
+
} else if (actualActiveValue === value) newState = null;else newState = value;
|
|
29
33
|
setInternalActiveValue(newState);
|
|
30
34
|
return onChange(newState, e);
|
|
31
35
|
}, [actualActiveValue, allowMultipleOpen, onChange]);
|
|
@@ -38,7 +42,5 @@ const useAccordion = (props) => {
|
|
|
38
42
|
}), [actualActiveValue, allChildrenReferences, focusableChildrenReferences, propsWithDefaults, setActiveValues]);
|
|
39
43
|
return ctx;
|
|
40
44
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=useAccordion.js.map
|
|
45
|
+
|
|
46
|
+
export { useAccordion };
|
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
const useAccordionRefs = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children
|
|
8
|
+
} = _ref;
|
|
9
|
+
return useMemo(() => {
|
|
10
|
+
const focusableChildrenReferences = [];
|
|
11
|
+
const allChildrenReferences = {};
|
|
12
|
+
React.Children.map(children, (child, index) => {
|
|
13
|
+
const {
|
|
14
|
+
value,
|
|
15
|
+
disabled
|
|
16
|
+
} = child.props;
|
|
17
|
+
const currentRef = /*#__PURE__*/React.createRef();
|
|
18
|
+
allChildrenReferences[index] = currentRef;
|
|
19
|
+
if (!disabled) focusableChildrenReferences.push({
|
|
20
|
+
index,
|
|
21
|
+
value,
|
|
22
|
+
ref: currentRef
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
focusableChildrenReferences,
|
|
27
|
+
allChildrenReferences
|
|
28
|
+
};
|
|
29
|
+
}, [children]);
|
|
17
30
|
};
|
|
18
|
-
|
|
31
|
+
|
|
32
|
+
export { useAccordionRefs };
|
package/esm/defaultProps.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
1
|
+
import _jsx2 from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { ChevronRight, ArrowheadRight, ChevronDown, ArrowheadDown } from '@elliemae/ds-icons';
|
|
4
|
+
|
|
5
|
+
var _ChevronRight, _ArrowheadRight, _ChevronDown, _ArrowheadDown;
|
|
6
|
+
const DefaultIconClosed = /*#__PURE__*/memo(_ref => {
|
|
7
|
+
let {
|
|
8
|
+
isDSMobile = false
|
|
9
|
+
} = _ref;
|
|
10
|
+
return isDSMobile ? _ChevronRight || (_ChevronRight = /*#__PURE__*/_jsx2(ChevronRight, {
|
|
11
|
+
width: "20px"
|
|
12
|
+
})) : _ArrowheadRight || (_ArrowheadRight = /*#__PURE__*/_jsx2(ArrowheadRight, {
|
|
13
|
+
width: "20px"
|
|
14
|
+
}));
|
|
15
|
+
});
|
|
16
|
+
const DefaultIconOpen = /*#__PURE__*/memo(_ref2 => {
|
|
17
|
+
let {
|
|
18
|
+
isDSMobile = false
|
|
19
|
+
} = _ref2;
|
|
20
|
+
return isDSMobile ? _ChevronDown || (_ChevronDown = /*#__PURE__*/_jsx2(ChevronDown, {
|
|
21
|
+
width: "20px"
|
|
22
|
+
})) : _ArrowheadDown || (_ArrowheadDown = /*#__PURE__*/_jsx2(ArrowheadDown, {
|
|
23
|
+
width: "20px"
|
|
24
|
+
}));
|
|
25
|
+
}); // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
26
|
+
|
|
27
|
+
const noop = () => {};
|
|
28
|
+
|
|
16
29
|
const defaultProps = {
|
|
17
30
|
containerProps: {},
|
|
18
31
|
allowMultipleOpen: false,
|
|
@@ -24,12 +37,9 @@ const defaultProps = {
|
|
|
24
37
|
const accordionItemDefaultProps = {
|
|
25
38
|
iconClosed: DefaultIconClosed,
|
|
26
39
|
iconOpened: DefaultIconOpen,
|
|
27
|
-
title:
|
|
40
|
+
title: '',
|
|
28
41
|
customActions: [],
|
|
29
42
|
disabled: false
|
|
30
43
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
defaultProps
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=defaultProps.js.map
|
|
44
|
+
|
|
45
|
+
export { accordionItemDefaultProps, defaultProps };
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export * from "./parts/accordionItem/DSAccordionItem";
|
|
4
|
-
import { default as default2 } from "./DSAccordion";
|
|
5
|
-
export {
|
|
6
|
-
default2 as default
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSAccordion, DSAccordionWithSchema, DSAccordion as default } from './DSAccordion.js';
|
|
2
|
+
export { DSAccordionItem, DSAccordionItemWithSchema } from './parts/accordionItem/DSAccordionItem.js';
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import { DSAccordionContext } from '../../DSAccordionCTX.js';
|
|
9
|
+
import { DSAccordionDataTestid } from '../../DSAccordionDatatestid.js';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
15
|
const AccordionContent = () => {
|
|
6
16
|
const {
|
|
7
|
-
props: {
|
|
17
|
+
props: {
|
|
18
|
+
containerProps,
|
|
19
|
+
children
|
|
20
|
+
}
|
|
8
21
|
} = useContext(DSAccordionContext);
|
|
9
22
|
const childrenWithIndex = [];
|
|
10
|
-
|
|
23
|
+
React.Children.forEach(children, (child, index) => childrenWithIndex.push( /*#__PURE__*/React.cloneElement(child, {
|
|
11
24
|
dsIndex: index
|
|
12
25
|
})));
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
26
|
+
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
27
|
+
"data-testid": DSAccordionDataTestid.GROUP,
|
|
28
|
+
children: childrenWithIndex
|
|
29
|
+
}));
|
|
17
30
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=AccordionContent.js.map
|
|
31
|
+
|
|
32
|
+
export { AccordionContent };
|
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from
|
|
19
|
-
import { accordionItemPropTypes } from
|
|
20
|
-
import { useAccordionItem } from
|
|
21
|
-
import { DSAccordionContext } from
|
|
22
|
-
import { DSAccordionDataTestid } from
|
|
23
|
-
import { useIsShowingEllipsis } from
|
|
24
|
-
|
|
1
|
+
import _jsx2 from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
12
|
+
import { useContext, useCallback, useState, useMemo } from 'react';
|
|
13
|
+
import { describe } from 'react-desc';
|
|
14
|
+
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
15
|
+
import DSButton, { BUTTON_TYPE } from '@elliemae/ds-button';
|
|
16
|
+
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
17
|
+
import { accordionItemDefaultProps } from '../../defaultProps.js';
|
|
18
|
+
import { StyledItemCustomActions, StyledPrimaryTitle, StyledSecondaryTitle, StyledItemContainer, StyledItemHeaderContainer, StyledItemHeader, StyledItemAddon, StyledItemTitles, StyledItemContent } from './styles.js';
|
|
19
|
+
import { accordionItemPropTypes } from '../../propTypes.js';
|
|
20
|
+
import { useAccordionItem } from './useAccordionItem.js';
|
|
21
|
+
import { DSAccordionContext } from '../../DSAccordionCTX.js';
|
|
22
|
+
import { DSAccordionDataTestid } from '../../DSAccordionDatatestid.js';
|
|
23
|
+
import { useIsShowingEllipsis } from './useIsShowingEllipsis.js';
|
|
24
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
25
|
+
|
|
26
|
+
const _excluded = ["onClick", "id"];
|
|
27
|
+
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
+
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
+
|
|
32
|
+
const DSAccordionItem = props => {
|
|
25
33
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, accordionItemDefaultProps);
|
|
26
34
|
const {
|
|
27
35
|
children,
|
|
@@ -35,126 +43,151 @@ const DSAccordionItem = (props) => {
|
|
|
35
43
|
dsIndex,
|
|
36
44
|
renderCustomActions
|
|
37
45
|
} = propsWithDefaults;
|
|
38
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
handleOnClick,
|
|
48
|
+
handleOnKeyDown,
|
|
49
|
+
selected
|
|
50
|
+
} = useAccordionItem({
|
|
51
|
+
value,
|
|
52
|
+
disabled
|
|
53
|
+
});
|
|
39
54
|
const {
|
|
40
55
|
allChildrenReferences,
|
|
41
56
|
actualActiveValue,
|
|
42
|
-
props: {
|
|
57
|
+
props: {
|
|
58
|
+
isDSMobile
|
|
59
|
+
}
|
|
43
60
|
} = useContext(DSAccordionContext);
|
|
44
|
-
const onKeyDownWithIndex = useCallback(
|
|
61
|
+
const onKeyDownWithIndex = useCallback(e => {
|
|
45
62
|
handleOnKeyDown(e, dsIndex);
|
|
46
63
|
}, [dsIndex, handleOnKeyDown]);
|
|
47
64
|
const [showPopover, setShowPopover] = useState(false);
|
|
48
65
|
const [referenceElement, setReferenceElement] = useState();
|
|
49
66
|
const CustomActionsContent = useMemo(() => {
|
|
50
|
-
if (!isDSMobile && customActions
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
if (!isDSMobile && (customActions === null || customActions === void 0 ? void 0 : customActions.length) > 0) return /*#__PURE__*/_jsx2(StyledItemCustomActions, {}, void 0, customActions === null || customActions === void 0 ? void 0 : customActions.map(_ref => {
|
|
68
|
+
let {
|
|
69
|
+
onClick,
|
|
70
|
+
id
|
|
71
|
+
} = _ref,
|
|
72
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
73
|
+
|
|
74
|
+
return /*#__PURE__*/jsx(DSButton, _objectSpread(_objectSpread({
|
|
75
|
+
onClick: e => {
|
|
54
76
|
e.stopPropagation();
|
|
55
|
-
if (onClick)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...rest,
|
|
77
|
+
if (onClick) onClick(e);
|
|
78
|
+
}
|
|
79
|
+
}, rest), {}, {
|
|
59
80
|
buttonType: BUTTON_TYPE.SECONDARY
|
|
60
|
-
}))
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
}), id);
|
|
82
|
+
}));
|
|
83
|
+
if (!isDSMobile && renderCustomActions) return /*#__PURE__*/_jsx2(StyledItemCustomActions, {}, void 0, renderCustomActions({
|
|
84
|
+
allRefs: allChildrenReferences,
|
|
85
|
+
actualActiveValue
|
|
86
|
+
}));
|
|
63
87
|
return null;
|
|
64
88
|
}, [actualActiveValue, allChildrenReferences, customActions, isDSMobile, renderCustomActions]);
|
|
65
|
-
const {
|
|
66
|
-
|
|
89
|
+
const {
|
|
90
|
+
isShowingEllipsis: isPrimaryShowingEllipsis,
|
|
91
|
+
setElement: setPrimaryElement
|
|
92
|
+
} = useIsShowingEllipsis();
|
|
93
|
+
const {
|
|
94
|
+
isShowingEllipsis: isSecondaryShowingEllipsis,
|
|
95
|
+
setElement: setSecondaryElement
|
|
96
|
+
} = useIsShowingEllipsis();
|
|
67
97
|
const handleOnFocus = useCallback(() => setShowPopover(isPrimaryShowingEllipsis || isSecondaryShowingEllipsis), [isPrimaryShowingEllipsis, isSecondaryShowingEllipsis]);
|
|
68
98
|
const handleOnBlur = useCallback(() => setShowPopover(false), []);
|
|
69
99
|
const Titles = useMemo(() => {
|
|
70
|
-
if (isPrimaryShowingEllipsis || isSecondaryShowingEllipsis)
|
|
71
|
-
|
|
100
|
+
if (isPrimaryShowingEllipsis || isSecondaryShowingEllipsis) return /*#__PURE__*/jsxs(Fragment, {
|
|
101
|
+
children: [/*#__PURE__*/jsx(StyledPrimaryTitle, {
|
|
72
102
|
ref: setPrimaryElement,
|
|
73
|
-
id:
|
|
74
|
-
disabled,
|
|
75
|
-
isDSMobile
|
|
76
|
-
|
|
103
|
+
id: "accordion_".concat(title, "id"),
|
|
104
|
+
disabled: disabled,
|
|
105
|
+
isDSMobile: isDSMobile,
|
|
106
|
+
children: title
|
|
107
|
+
}), !isDSMobile && secondaryTitle && /*#__PURE__*/jsx(StyledSecondaryTitle, {
|
|
77
108
|
ref: setSecondaryElement,
|
|
78
|
-
disabled
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
disabled: disabled,
|
|
110
|
+
children: secondaryTitle
|
|
111
|
+
}), /*#__PURE__*/_jsx2(DSPopperJS, {
|
|
112
|
+
referenceElement: referenceElement,
|
|
113
|
+
showPopover: showPopover
|
|
114
|
+
}, void 0, /*#__PURE__*/_jsx2("div", {
|
|
115
|
+
style: {
|
|
116
|
+
maxWidth: 260,
|
|
117
|
+
padding: 8,
|
|
118
|
+
background: 'white',
|
|
119
|
+
display: 'grid',
|
|
120
|
+
gap: 8
|
|
121
|
+
}
|
|
122
|
+
}, void 0, /*#__PURE__*/_jsx2("p", {
|
|
123
|
+
style: {
|
|
124
|
+
margin: 0
|
|
125
|
+
}
|
|
126
|
+
}, void 0, title), /*#__PURE__*/_jsx2("p", {
|
|
127
|
+
style: {
|
|
128
|
+
margin: 0
|
|
129
|
+
}
|
|
130
|
+
}, void 0, " ", secondaryTitle)))]
|
|
131
|
+
});
|
|
132
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
133
|
+
children: [/*#__PURE__*/jsx(StyledPrimaryTitle, {
|
|
134
|
+
ref: setPrimaryElement,
|
|
135
|
+
id: "accordion_".concat(title, "id"),
|
|
136
|
+
disabled: disabled,
|
|
137
|
+
isDSMobile: isDSMobile,
|
|
138
|
+
children: title
|
|
139
|
+
}), !isDSMobile && secondaryTitle && /*#__PURE__*/jsx(StyledSecondaryTitle, {
|
|
140
|
+
ref: setSecondaryElement,
|
|
141
|
+
disabled: disabled,
|
|
142
|
+
children: secondaryTitle
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
}, [disabled, isDSMobile, isPrimaryShowingEllipsis, isSecondaryShowingEllipsis, referenceElement, secondaryTitle, setPrimaryElement, setSecondaryElement, showPopover, title]);
|
|
146
|
+
return /*#__PURE__*/_jsx2(StyledItemContainer, {
|
|
111
147
|
"data-testid": DSAccordionDataTestid.ITEM.CONTAINER
|
|
112
|
-
},
|
|
113
|
-
disabled
|
|
114
|
-
},
|
|
115
|
-
withCustomActions: (customActions
|
|
148
|
+
}, void 0, /*#__PURE__*/_jsx2(StyledItemHeaderContainer, {
|
|
149
|
+
disabled: disabled
|
|
150
|
+
}, void 0, /*#__PURE__*/jsxs(StyledItemHeader, {
|
|
151
|
+
withCustomActions: ((customActions === null || customActions === void 0 ? void 0 : customActions.length) > 0 || renderCustomActions !== undefined) && !isDSMobile,
|
|
116
152
|
withSecondaryTitle: secondaryTitle,
|
|
117
153
|
onClick: handleOnClick,
|
|
118
|
-
tabIndex: !disabled ? 0 :
|
|
119
|
-
disabled,
|
|
154
|
+
tabIndex: !disabled ? 0 : undefined,
|
|
155
|
+
disabled: disabled,
|
|
120
156
|
"data-disabled": disabled,
|
|
121
157
|
ref: allChildrenReferences[dsIndex],
|
|
122
158
|
onKeyDown: onKeyDownWithIndex,
|
|
123
|
-
isDSMobile,
|
|
159
|
+
isDSMobile: isDSMobile,
|
|
124
160
|
"data-testid": DSAccordionDataTestid.ITEM.HEADER,
|
|
125
|
-
id:
|
|
161
|
+
id: "ds-accordion-header-".concat(value),
|
|
126
162
|
"aria-expanded": selected,
|
|
127
163
|
"aria-disabled": disabled,
|
|
128
|
-
"aria-controls":
|
|
164
|
+
"aria-controls": "ds-accordion-content-".concat(value),
|
|
129
165
|
onFocus: handleOnFocus,
|
|
130
|
-
onBlur: handleOnBlur
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
166
|
+
onBlur: handleOnBlur,
|
|
167
|
+
children: [/*#__PURE__*/_jsx2(StyledItemAddon, {
|
|
168
|
+
disabled: disabled,
|
|
169
|
+
isDSMobile: isDSMobile
|
|
170
|
+
}, void 0, selected ? /*#__PURE__*/_jsx2(IconOpened, {
|
|
171
|
+
isDSMobile: isDSMobile
|
|
172
|
+
}) : /*#__PURE__*/_jsx2(IconClosed, {
|
|
173
|
+
isDSMobile: isDSMobile
|
|
174
|
+
})), /*#__PURE__*/jsx(StyledItemTitles, {
|
|
175
|
+
onMouseEnter: handleOnFocus,
|
|
176
|
+
onMouseLeave: handleOnBlur,
|
|
177
|
+
isDSMobile: isDSMobile,
|
|
178
|
+
ref: setReferenceElement,
|
|
179
|
+
children: Titles
|
|
180
|
+
})]
|
|
181
|
+
}), CustomActionsContent), selected && /*#__PURE__*/_jsx2(StyledItemContent, {
|
|
144
182
|
"data-testid": DSAccordionDataTestid.ITEM.CONTENT,
|
|
145
|
-
"aria-labelledby":
|
|
183
|
+
"aria-labelledby": "ds-accordion-header-".concat(value),
|
|
146
184
|
role: "region",
|
|
147
|
-
isDSMobile,
|
|
148
|
-
id:
|
|
149
|
-
}, children));
|
|
185
|
+
isDSMobile: isDSMobile,
|
|
186
|
+
id: "ds-accordion-content-".concat(value)
|
|
187
|
+
}, void 0, children));
|
|
150
188
|
};
|
|
151
|
-
|
|
189
|
+
|
|
152
190
|
const DSAccordionItemWithSchema = describe(DSAccordionItem);
|
|
153
191
|
DSAccordionItemWithSchema.propTypes = accordionItemPropTypes;
|
|
154
|
-
|
|
155
|
-
export {
|
|
156
|
-
DSAccordionItem,
|
|
157
|
-
DSAccordionItemWithSchema,
|
|
158
|
-
DSAccordionItem_default as default
|
|
159
|
-
};
|
|
160
|
-
//# sourceMappingURL=DSAccordionItem.js.map
|
|
192
|
+
|
|
193
|
+
export { DSAccordionItem, DSAccordionItemWithSchema, DSAccordionItem as default };
|