@elliemae/ds-accordion 2.3.0-alpha.8 → 2.3.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 +31 -0
- package/cjs/DSAccordionCTX.js +20 -0
- package/cjs/DSAccordionDatatestid.js +14 -0
- package/cjs/DSAccordionTypes.js +2 -0
- package/cjs/config/useAccordion.js +50 -0
- package/cjs/config/useAccordionRefs.js +40 -0
- package/cjs/defaultProps.js +54 -0
- package/cjs/index.js +14 -0
- package/cjs/parts/accordionContent/AccordionContent.js +41 -0
- package/cjs/parts/accordionItem/DSAccordionItem.js +206 -0
- package/cjs/parts/accordionItem/styles.js +149 -0
- package/cjs/parts/accordionItem/useAccordionItem.js +53 -0
- package/cjs/propTypes.js +26 -0
- package/esm/DSAccordion.js +21 -0
- package/esm/DSAccordionCTX.js +16 -0
- package/esm/DSAccordionDatatestid.js +10 -0
- package/esm/DSAccordionTypes.js +1 -0
- package/esm/config/useAccordion.js +46 -0
- package/esm/config/useAccordionRefs.js +32 -0
- package/esm/defaultProps.js +45 -0
- package/esm/index.js +2 -0
- package/esm/parts/accordionContent/AccordionContent.js +32 -0
- package/esm/parts/accordionItem/DSAccordionItem.js +193 -0
- package/esm/parts/accordionItem/styles.js +133 -0
- package/esm/parts/accordionItem/useAccordionItem.js +49 -0
- package/esm/propTypes.js +21 -0
- package/package.json +47 -52
- package/types/DSAccordion.d.ts +45 -0
- package/types/DSAccordionCTX.d.ts +3 -0
- package/types/DSAccordionDatatestid.d.ts +8 -0
- package/types/DSAccordionTypes.d.ts +137 -0
- package/types/config/useAccordion.d.ts +2 -0
- package/types/config/useAccordionRefs.d.ts +2 -0
- package/types/defaultProps.d.ts +3 -0
- package/types/index.d.ts +4 -0
- package/types/parts/accordionContent/AccordionContent.d.ts +2 -0
- package/types/parts/accordionItem/DSAccordionItem.d.ts +53 -0
- package/types/parts/accordionItem/styles.d.ts +10 -0
- package/types/parts/accordionItem/useAccordionItem.d.ts +2 -0
- package/types/propTypes.d.ts +73 -0
- package/types/tests/Accordion.test.d.ts +1 -0
- package/dist/cjs/DSAccordion.js +0 -52
- package/dist/cjs/DSAccordion.js.map +0 -7
- package/dist/cjs/DSAccordionCTX.js +0 -46
- package/dist/cjs/DSAccordionCTX.js.map +0 -7
- package/dist/cjs/DSAccordionDatatestid.js +0 -42
- package/dist/cjs/DSAccordionDatatestid.js.map +0 -7
- package/dist/cjs/DSAccordionTypes.js +0 -27
- package/dist/cjs/DSAccordionTypes.js.map +0 -7
- package/dist/cjs/config/useAccordion.js +0 -73
- package/dist/cjs/config/useAccordion.js.map +0 -7
- package/dist/cjs/config/useAccordionRefs.js +0 -47
- package/dist/cjs/config/useAccordionRefs.js.map +0 -7
- package/dist/cjs/defaultProps.js +0 -64
- package/dist/cjs/defaultProps.js.map +0 -7
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/parts/accordionContent/AccordionContent.js +0 -50
- package/dist/cjs/parts/accordionContent/AccordionContent.js.map +0 -7
- package/dist/cjs/parts/accordionItem/DSAccordionItem.js +0 -179
- package/dist/cjs/parts/accordionItem/DSAccordionItem.js.map +0 -7
- package/dist/cjs/parts/accordionItem/styles.js +0 -143
- package/dist/cjs/parts/accordionItem/styles.js.map +0 -7
- package/dist/cjs/parts/accordionItem/useAccordionItem.js +0 -66
- package/dist/cjs/parts/accordionItem/useAccordionItem.js.map +0 -7
- package/dist/cjs/propTypes.js +0 -57
- package/dist/cjs/propTypes.js.map +0 -7
- package/dist/esm/DSAccordion.js +0 -23
- package/dist/esm/DSAccordion.js.map +0 -7
- package/dist/esm/DSAccordionCTX.js +0 -17
- package/dist/esm/DSAccordionCTX.js.map +0 -7
- package/dist/esm/DSAccordionDatatestid.js +0 -13
- package/dist/esm/DSAccordionDatatestid.js.map +0 -7
- package/dist/esm/DSAccordionTypes.js +0 -2
- package/dist/esm/DSAccordionTypes.js.map +0 -7
- package/dist/esm/config/useAccordion.js +0 -44
- package/dist/esm/config/useAccordion.js.map +0 -7
- package/dist/esm/config/useAccordionRefs.js +0 -18
- package/dist/esm/config/useAccordionRefs.js.map +0 -7
- package/dist/esm/defaultProps.js +0 -35
- package/dist/esm/defaultProps.js.map +0 -7
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/parts/accordionContent/AccordionContent.js +0 -21
- package/dist/esm/parts/accordionContent/AccordionContent.js.map +0 -7
- package/dist/esm/parts/accordionItem/DSAccordionItem.js +0 -160
- package/dist/esm/parts/accordionItem/DSAccordionItem.js.map +0 -7
- package/dist/esm/parts/accordionItem/styles.js +0 -114
- package/dist/esm/parts/accordionItem/styles.js.map +0 -7
- package/dist/esm/parts/accordionItem/useAccordionItem.js +0 -37
- package/dist/esm/parts/accordionItem/useAccordionItem.js.map +0 -7
- package/dist/esm/propTypes.js +0 -28
- package/dist/esm/propTypes.js.map +0 -7
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('react');
|
|
7
|
+
var reactDesc = require('react-desc');
|
|
8
|
+
var AccordionContent = require('./parts/accordionContent/AccordionContent.js');
|
|
9
|
+
var useAccordion = require('./config/useAccordion.js');
|
|
10
|
+
var DSAccordionCTX = require('./DSAccordionCTX.js');
|
|
11
|
+
var propTypes = require('./propTypes.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
|
|
16
|
+
|
|
17
|
+
var _AccordionContent;
|
|
18
|
+
|
|
19
|
+
const DSAccordion = props => {
|
|
20
|
+
const ctx = useAccordion.useAccordion(props);
|
|
21
|
+
return /*#__PURE__*/_jsx2__default["default"](DSAccordionCTX.DSAccordionContext.Provider, {
|
|
22
|
+
value: ctx
|
|
23
|
+
}, void 0, _AccordionContent || (_AccordionContent = /*#__PURE__*/_jsx2__default["default"](AccordionContent.AccordionContent, {})));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const DSAccordionWithSchema = reactDesc.describe(DSAccordion);
|
|
27
|
+
DSAccordionWithSchema.propTypes = propTypes.accordionPropTypes;
|
|
28
|
+
|
|
29
|
+
exports.DSAccordion = DSAccordion;
|
|
30
|
+
exports.DSAccordionWithSchema = DSAccordionWithSchema;
|
|
31
|
+
exports["default"] = DSAccordion;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var defaultProps = require('./defaultProps.js');
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
9
|
+
const noop = () => {};
|
|
10
|
+
|
|
11
|
+
const defaultContext = {
|
|
12
|
+
props: defaultProps.defaultProps,
|
|
13
|
+
actualActiveValue: [],
|
|
14
|
+
setActiveValues: noop,
|
|
15
|
+
focusableChildrenReferences: [],
|
|
16
|
+
allChildrenReferences: {}
|
|
17
|
+
};
|
|
18
|
+
const DSAccordionContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
19
|
+
|
|
20
|
+
exports.DSAccordionContext = DSAccordionContext;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const DSAccordionDataTestid = {
|
|
6
|
+
ITEM: {
|
|
7
|
+
CONTENT: 'ds-accordion_item-content',
|
|
8
|
+
HEADER: 'ds-accordion_item-header',
|
|
9
|
+
CONTAINER: 'ds-accordion_item'
|
|
10
|
+
},
|
|
11
|
+
GROUP: 'ds-accordion_group'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.DSAccordionDataTestid = DSAccordionDataTestid;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.some.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.some.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
13
|
+
var useAccordionRefs = require('./useAccordionRefs.js');
|
|
14
|
+
var defaultProps = require('../defaultProps.js');
|
|
15
|
+
|
|
16
|
+
const useAccordion = props => {
|
|
17
|
+
const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props, defaultProps.defaultProps);
|
|
18
|
+
const {
|
|
19
|
+
activeValue,
|
|
20
|
+
allowMultipleOpen,
|
|
21
|
+
onChange
|
|
22
|
+
} = propsWithDefaults;
|
|
23
|
+
const {
|
|
24
|
+
focusableChildrenReferences,
|
|
25
|
+
allChildrenReferences
|
|
26
|
+
} = useAccordionRefs.useAccordionRefs(propsWithDefaults);
|
|
27
|
+
const [internalActiveValue, setInternalActiveValue] = React.useState(activeValue);
|
|
28
|
+
const actualActiveValue = React.useMemo(() => {
|
|
29
|
+
if (activeValue === undefined) return internalActiveValue;
|
|
30
|
+
return activeValue;
|
|
31
|
+
}, [activeValue, internalActiveValue]);
|
|
32
|
+
const setActiveValues = React.useCallback((value, e) => {
|
|
33
|
+
let newState;
|
|
34
|
+
if (allowMultipleOpen && (actualActiveValue === undefined || actualActiveValue === null)) newState = [value];else if (allowMultipleOpen && Array.isArray(actualActiveValue)) {
|
|
35
|
+
if (!actualActiveValue.some(currentValues => currentValues === value)) newState = [...actualActiveValue, value];else newState = actualActiveValue.filter(currentValues => currentValues !== value);
|
|
36
|
+
} else if (actualActiveValue === value) newState = null;else newState = value;
|
|
37
|
+
setInternalActiveValue(newState);
|
|
38
|
+
return onChange(newState, e);
|
|
39
|
+
}, [actualActiveValue, allowMultipleOpen, onChange]);
|
|
40
|
+
const ctx = React.useMemo(() => ({
|
|
41
|
+
props: propsWithDefaults,
|
|
42
|
+
actualActiveValue,
|
|
43
|
+
setActiveValues,
|
|
44
|
+
focusableChildrenReferences,
|
|
45
|
+
allChildrenReferences
|
|
46
|
+
}), [actualActiveValue, allChildrenReferences, focusableChildrenReferences, propsWithDefaults, setActiveValues]);
|
|
47
|
+
return ctx;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.useAccordion = useAccordion;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
13
|
+
const useAccordionRefs = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
children
|
|
16
|
+
} = _ref;
|
|
17
|
+
return React.useMemo(() => {
|
|
18
|
+
const focusableChildrenReferences = [];
|
|
19
|
+
const allChildrenReferences = {};
|
|
20
|
+
React__default["default"].Children.map(children, (child, index) => {
|
|
21
|
+
const {
|
|
22
|
+
value,
|
|
23
|
+
disabled
|
|
24
|
+
} = child.props;
|
|
25
|
+
const currentRef = /*#__PURE__*/React__default["default"].createRef();
|
|
26
|
+
allChildrenReferences[index] = currentRef;
|
|
27
|
+
if (!disabled) focusableChildrenReferences.push({
|
|
28
|
+
index,
|
|
29
|
+
value,
|
|
30
|
+
ref: currentRef
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
focusableChildrenReferences,
|
|
35
|
+
allChildrenReferences
|
|
36
|
+
};
|
|
37
|
+
}, [children]);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.useAccordionRefs = useAccordionRefs;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
|
|
12
|
+
|
|
13
|
+
var _ChevronRight, _ArrowheadRight, _ChevronDown, _ArrowheadDown;
|
|
14
|
+
const DefaultIconClosed = /*#__PURE__*/React.memo(_ref => {
|
|
15
|
+
let {
|
|
16
|
+
isDSMobile = false
|
|
17
|
+
} = _ref;
|
|
18
|
+
return isDSMobile ? _ChevronRight || (_ChevronRight = /*#__PURE__*/_jsx2__default["default"](dsIcons.ChevronRight, {
|
|
19
|
+
width: "20px"
|
|
20
|
+
})) : _ArrowheadRight || (_ArrowheadRight = /*#__PURE__*/_jsx2__default["default"](dsIcons.ArrowheadRight, {
|
|
21
|
+
width: "20px"
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
const DefaultIconOpen = /*#__PURE__*/React.memo(_ref2 => {
|
|
25
|
+
let {
|
|
26
|
+
isDSMobile = false
|
|
27
|
+
} = _ref2;
|
|
28
|
+
return isDSMobile ? _ChevronDown || (_ChevronDown = /*#__PURE__*/_jsx2__default["default"](dsIcons.ChevronDown, {
|
|
29
|
+
width: "20px"
|
|
30
|
+
})) : _ArrowheadDown || (_ArrowheadDown = /*#__PURE__*/_jsx2__default["default"](dsIcons.ArrowheadDown, {
|
|
31
|
+
width: "20px"
|
|
32
|
+
}));
|
|
33
|
+
}); // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
34
|
+
|
|
35
|
+
const noop = () => {};
|
|
36
|
+
|
|
37
|
+
const defaultProps = {
|
|
38
|
+
containerProps: {},
|
|
39
|
+
allowMultipleOpen: false,
|
|
40
|
+
contentExpandable: false,
|
|
41
|
+
onChange: noop,
|
|
42
|
+
children: [],
|
|
43
|
+
isDSMobile: false
|
|
44
|
+
};
|
|
45
|
+
const accordionItemDefaultProps = {
|
|
46
|
+
iconClosed: DefaultIconClosed,
|
|
47
|
+
iconOpened: DefaultIconOpen,
|
|
48
|
+
title: '',
|
|
49
|
+
customActions: [],
|
|
50
|
+
disabled: false
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.accordionItemDefaultProps = accordionItemDefaultProps;
|
|
54
|
+
exports.defaultProps = defaultProps;
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSAccordion = require('./DSAccordion.js');
|
|
6
|
+
var DSAccordionItem = require('./parts/accordionItem/DSAccordionItem.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.DSAccordion = DSAccordion.DSAccordion;
|
|
11
|
+
exports.DSAccordionWithSchema = DSAccordion.DSAccordionWithSchema;
|
|
12
|
+
exports["default"] = DSAccordion.DSAccordion;
|
|
13
|
+
exports.DSAccordionItem = DSAccordionItem.DSAccordionItem;
|
|
14
|
+
exports.DSAccordionItemWithSchema = DSAccordionItem.DSAccordionItemWithSchema;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var DSAccordionCTX = require('../../DSAccordionCTX.js');
|
|
13
|
+
var DSAccordionDatatestid = require('../../DSAccordionDatatestid.js');
|
|
14
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
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__default["default"](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; }
|
|
24
|
+
const AccordionContent = () => {
|
|
25
|
+
const {
|
|
26
|
+
props: {
|
|
27
|
+
containerProps,
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
} = React.useContext(DSAccordionCTX.DSAccordionContext);
|
|
31
|
+
const childrenWithIndex = [];
|
|
32
|
+
React__default["default"].Children.forEach(children, (child, index) => childrenWithIndex.push( /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
33
|
+
dsIndex: index
|
|
34
|
+
})));
|
|
35
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
36
|
+
"data-testid": DSAccordionDatatestid.DSAccordionDataTestid.GROUP,
|
|
37
|
+
children: childrenWithIndex
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.AccordionContent = AccordionContent;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
14
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
15
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var reactDesc = require('react-desc');
|
|
18
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
19
|
+
var DSButton = require('@elliemae/ds-button');
|
|
20
|
+
var dsPopperjs = require('@elliemae/ds-popperjs');
|
|
21
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
22
|
+
var defaultProps = require('../../defaultProps.js');
|
|
23
|
+
var styles = require('./styles.js');
|
|
24
|
+
var propTypes = require('../../propTypes.js');
|
|
25
|
+
var useAccordionItem = require('./useAccordionItem.js');
|
|
26
|
+
var DSAccordionCTX = require('../../DSAccordionCTX.js');
|
|
27
|
+
var DSAccordionDatatestid = require('../../DSAccordionDatatestid.js');
|
|
28
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
29
|
+
|
|
30
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
|
+
|
|
32
|
+
var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
|
|
33
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
34
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
35
|
+
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
36
|
+
|
|
37
|
+
const _excluded = ["onClick", "id"];
|
|
38
|
+
|
|
39
|
+
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; }
|
|
40
|
+
|
|
41
|
+
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__default["default"](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; }
|
|
42
|
+
|
|
43
|
+
const DSAccordionItem = props => {
|
|
44
|
+
const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props, defaultProps.accordionItemDefaultProps);
|
|
45
|
+
const {
|
|
46
|
+
children,
|
|
47
|
+
title,
|
|
48
|
+
secondaryTitle,
|
|
49
|
+
customActions,
|
|
50
|
+
iconOpened: IconOpened,
|
|
51
|
+
iconClosed: IconClosed,
|
|
52
|
+
value,
|
|
53
|
+
disabled,
|
|
54
|
+
dsIndex,
|
|
55
|
+
renderCustomActions
|
|
56
|
+
} = propsWithDefaults;
|
|
57
|
+
const {
|
|
58
|
+
handleOnClick,
|
|
59
|
+
handleOnKeyDown,
|
|
60
|
+
selected
|
|
61
|
+
} = useAccordionItem.useAccordionItem({
|
|
62
|
+
value,
|
|
63
|
+
disabled
|
|
64
|
+
});
|
|
65
|
+
const {
|
|
66
|
+
allChildrenReferences,
|
|
67
|
+
actualActiveValue,
|
|
68
|
+
props: {
|
|
69
|
+
isDSMobile
|
|
70
|
+
}
|
|
71
|
+
} = React.useContext(DSAccordionCTX.DSAccordionContext);
|
|
72
|
+
const onKeyDownWithIndex = React.useCallback(e => {
|
|
73
|
+
handleOnKeyDown(e, dsIndex);
|
|
74
|
+
}, [dsIndex, handleOnKeyDown]);
|
|
75
|
+
const [showPopover, setShowPopover] = React.useState(false);
|
|
76
|
+
const [referenceElement, setReferenceElement] = React.useState();
|
|
77
|
+
const CustomActionsContent = React.useMemo(() => {
|
|
78
|
+
if (!isDSMobile && (customActions === null || customActions === void 0 ? void 0 : customActions.length) > 0) return /*#__PURE__*/_jsx2__default["default"](styles.StyledItemCustomActions, {}, void 0, customActions === null || customActions === void 0 ? void 0 : customActions.map(_ref => {
|
|
79
|
+
let {
|
|
80
|
+
onClick,
|
|
81
|
+
id
|
|
82
|
+
} = _ref,
|
|
83
|
+
rest = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
84
|
+
|
|
85
|
+
return /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread(_objectSpread({
|
|
86
|
+
onClick: e => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
if (onClick) onClick(e);
|
|
89
|
+
}
|
|
90
|
+
}, rest), {}, {
|
|
91
|
+
buttonType: DSButton.BUTTON_TYPE.SECONDARY
|
|
92
|
+
}), id);
|
|
93
|
+
}));
|
|
94
|
+
if (!isDSMobile && renderCustomActions) return /*#__PURE__*/_jsx2__default["default"](styles.StyledItemCustomActions, {}, void 0, renderCustomActions({
|
|
95
|
+
allRefs: allChildrenReferences,
|
|
96
|
+
actualActiveValue
|
|
97
|
+
}));
|
|
98
|
+
return null;
|
|
99
|
+
}, [actualActiveValue, allChildrenReferences, customActions, isDSMobile, renderCustomActions]);
|
|
100
|
+
const {
|
|
101
|
+
isShowingEllipsis: isPrimaryShowingEllipsis,
|
|
102
|
+
setElement: setPrimaryElement
|
|
103
|
+
} = dsUtilities.useIsShowingEllipsis();
|
|
104
|
+
const {
|
|
105
|
+
isShowingEllipsis: isSecondaryShowingEllipsis,
|
|
106
|
+
setElement: setSecondaryElement
|
|
107
|
+
} = dsUtilities.useIsShowingEllipsis();
|
|
108
|
+
const handleOnFocus = React.useCallback(() => setShowPopover(isPrimaryShowingEllipsis || isSecondaryShowingEllipsis), [isPrimaryShowingEllipsis, isSecondaryShowingEllipsis]);
|
|
109
|
+
const handleOnBlur = React.useCallback(() => setShowPopover(false), []);
|
|
110
|
+
const Titles = React.useMemo(() => {
|
|
111
|
+
if (isPrimaryShowingEllipsis || isSecondaryShowingEllipsis) return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
112
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(styles.StyledPrimaryTitle, {
|
|
113
|
+
ref: setPrimaryElement,
|
|
114
|
+
id: "accordion_".concat(title, "id"),
|
|
115
|
+
disabled: disabled,
|
|
116
|
+
isDSMobile: isDSMobile,
|
|
117
|
+
children: title
|
|
118
|
+
}), !isDSMobile && secondaryTitle && /*#__PURE__*/jsxRuntime.jsx(styles.StyledSecondaryTitle, {
|
|
119
|
+
ref: setSecondaryElement,
|
|
120
|
+
disabled: disabled,
|
|
121
|
+
children: secondaryTitle
|
|
122
|
+
}), /*#__PURE__*/_jsx2__default["default"](dsPopperjs.DSPopperJS, {
|
|
123
|
+
referenceElement: referenceElement,
|
|
124
|
+
showPopover: showPopover
|
|
125
|
+
}, void 0, /*#__PURE__*/_jsx2__default["default"]("div", {
|
|
126
|
+
style: {
|
|
127
|
+
maxWidth: 260,
|
|
128
|
+
padding: 8,
|
|
129
|
+
background: 'white',
|
|
130
|
+
display: 'grid',
|
|
131
|
+
gap: 8
|
|
132
|
+
}
|
|
133
|
+
}, void 0, /*#__PURE__*/_jsx2__default["default"]("p", {
|
|
134
|
+
style: {
|
|
135
|
+
margin: 0
|
|
136
|
+
}
|
|
137
|
+
}, void 0, title), /*#__PURE__*/_jsx2__default["default"]("p", {
|
|
138
|
+
style: {
|
|
139
|
+
margin: 0
|
|
140
|
+
}
|
|
141
|
+
}, void 0, " ", secondaryTitle)))]
|
|
142
|
+
});
|
|
143
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
144
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(styles.StyledPrimaryTitle, {
|
|
145
|
+
ref: setPrimaryElement,
|
|
146
|
+
id: "accordion_".concat(title, "id"),
|
|
147
|
+
disabled: disabled,
|
|
148
|
+
isDSMobile: isDSMobile,
|
|
149
|
+
children: title
|
|
150
|
+
}), !isDSMobile && secondaryTitle && /*#__PURE__*/jsxRuntime.jsx(styles.StyledSecondaryTitle, {
|
|
151
|
+
ref: setSecondaryElement,
|
|
152
|
+
disabled: disabled,
|
|
153
|
+
children: secondaryTitle
|
|
154
|
+
})]
|
|
155
|
+
});
|
|
156
|
+
}, [disabled, isDSMobile, isPrimaryShowingEllipsis, isSecondaryShowingEllipsis, referenceElement, secondaryTitle, setPrimaryElement, setSecondaryElement, showPopover, title]);
|
|
157
|
+
return /*#__PURE__*/_jsx2__default["default"](styles.StyledItemContainer, {
|
|
158
|
+
"data-testid": DSAccordionDatatestid.DSAccordionDataTestid.ITEM.CONTAINER
|
|
159
|
+
}, void 0, /*#__PURE__*/_jsx2__default["default"](styles.StyledItemHeaderContainer, {
|
|
160
|
+
disabled: disabled
|
|
161
|
+
}, void 0, /*#__PURE__*/jsxRuntime.jsxs(styles.StyledItemHeader, {
|
|
162
|
+
withCustomActions: ((customActions === null || customActions === void 0 ? void 0 : customActions.length) > 0 || renderCustomActions !== undefined) && !isDSMobile,
|
|
163
|
+
withSecondaryTitle: secondaryTitle,
|
|
164
|
+
onClick: handleOnClick,
|
|
165
|
+
tabIndex: !disabled ? 0 : undefined,
|
|
166
|
+
disabled: disabled,
|
|
167
|
+
"data-disabled": disabled,
|
|
168
|
+
ref: allChildrenReferences[dsIndex],
|
|
169
|
+
onKeyDown: onKeyDownWithIndex,
|
|
170
|
+
isDSMobile: isDSMobile,
|
|
171
|
+
"data-testid": DSAccordionDatatestid.DSAccordionDataTestid.ITEM.HEADER,
|
|
172
|
+
id: "ds-accordion-header-".concat(value),
|
|
173
|
+
"aria-expanded": selected,
|
|
174
|
+
"aria-disabled": disabled,
|
|
175
|
+
"aria-controls": "ds-accordion-content-".concat(value),
|
|
176
|
+
onFocus: handleOnFocus,
|
|
177
|
+
onBlur: handleOnBlur,
|
|
178
|
+
children: [/*#__PURE__*/_jsx2__default["default"](styles.StyledItemAddon, {
|
|
179
|
+
disabled: disabled,
|
|
180
|
+
isDSMobile: isDSMobile
|
|
181
|
+
}, void 0, selected ? /*#__PURE__*/_jsx2__default["default"](IconOpened, {
|
|
182
|
+
isDSMobile: isDSMobile
|
|
183
|
+
}) : /*#__PURE__*/_jsx2__default["default"](IconClosed, {
|
|
184
|
+
isDSMobile: isDSMobile
|
|
185
|
+
})), /*#__PURE__*/jsxRuntime.jsx(styles.StyledItemTitles, {
|
|
186
|
+
onMouseEnter: handleOnFocus,
|
|
187
|
+
onMouseLeave: handleOnBlur,
|
|
188
|
+
isDSMobile: isDSMobile,
|
|
189
|
+
ref: setReferenceElement,
|
|
190
|
+
children: Titles
|
|
191
|
+
})]
|
|
192
|
+
}), CustomActionsContent), selected && /*#__PURE__*/_jsx2__default["default"](styles.StyledItemContent, {
|
|
193
|
+
"data-testid": DSAccordionDatatestid.DSAccordionDataTestid.ITEM.CONTENT,
|
|
194
|
+
"aria-labelledby": "ds-accordion-header-".concat(value),
|
|
195
|
+
role: "region",
|
|
196
|
+
isDSMobile: isDSMobile,
|
|
197
|
+
id: "ds-accordion-content-".concat(value)
|
|
198
|
+
}, void 0, children));
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const DSAccordionItemWithSchema = reactDesc.describe(DSAccordionItem);
|
|
202
|
+
DSAccordionItemWithSchema.propTypes = propTypes.accordionItemPropTypes;
|
|
203
|
+
|
|
204
|
+
exports.DSAccordionItem = DSAccordionItem;
|
|
205
|
+
exports.DSAccordionItemWithSchema = DSAccordionItemWithSchema;
|
|
206
|
+
exports["default"] = DSAccordionItem;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledItemContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
|
+
componentId: "sc-fnpjby-0"
|
|
13
|
+
})(["display:grid;grid-template-rows:auto auto;border-bottom:1px solid ", ";align-items:center;"], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
return theme.colors.neutral[200];
|
|
18
|
+
});
|
|
19
|
+
const StyledItemHeader = /*#__PURE__*/styled__default["default"].button.withConfig({
|
|
20
|
+
componentId: "sc-fnpjby-1"
|
|
21
|
+
})(["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 => {
|
|
22
|
+
let {
|
|
23
|
+
theme,
|
|
24
|
+
withSecondaryTitle
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return withSecondaryTitle ? theme.space.m : theme.space.s;
|
|
27
|
+
}, _ref3 => {
|
|
28
|
+
let {
|
|
29
|
+
disabled
|
|
30
|
+
} = _ref3;
|
|
31
|
+
return disabled ? 'not-allowed' : 'pointer';
|
|
32
|
+
}, _ref4 => {
|
|
33
|
+
let {
|
|
34
|
+
isDSMobile
|
|
35
|
+
} = _ref4;
|
|
36
|
+
return isDSMobile ? "0 16px" : "0";
|
|
37
|
+
}, _ref5 => {
|
|
38
|
+
let {
|
|
39
|
+
isDSMobile
|
|
40
|
+
} = _ref5;
|
|
41
|
+
return isDSMobile ? "flex-direction: row-reverse;" : "";
|
|
42
|
+
}, _ref6 => {
|
|
43
|
+
let {
|
|
44
|
+
theme
|
|
45
|
+
} = _ref6;
|
|
46
|
+
return theme.colors.brand[700];
|
|
47
|
+
});
|
|
48
|
+
const StyledItemContent = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
49
|
+
componentId: "sc-fnpjby-2"
|
|
50
|
+
})(["margin:", ";grid-column:1/2;"], _ref7 => {
|
|
51
|
+
let {
|
|
52
|
+
isDSMobile
|
|
53
|
+
} = _ref7;
|
|
54
|
+
return isDSMobile ? "16px 16px 24px 16px" : "16px 16px 16px 32px";
|
|
55
|
+
});
|
|
56
|
+
const StyledItemAddon = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
57
|
+
componentId: "sc-fnpjby-3"
|
|
58
|
+
})(["", " height:100%;width:", ";display:grid;place-items:center;& .em-ds-icon svg{fill:", ";}"], _ref8 => {
|
|
59
|
+
let {
|
|
60
|
+
theme,
|
|
61
|
+
isDSMobile
|
|
62
|
+
} = _ref8;
|
|
63
|
+
return !isDSMobile ? "padding: 0 ".concat(theme.space.xxs, ";") : "";
|
|
64
|
+
}, _ref9 => {
|
|
65
|
+
let {
|
|
66
|
+
theme
|
|
67
|
+
} = _ref9;
|
|
68
|
+
return theme.space.s;
|
|
69
|
+
}, _ref10 => {
|
|
70
|
+
let {
|
|
71
|
+
disabled,
|
|
72
|
+
theme
|
|
73
|
+
} = _ref10;
|
|
74
|
+
return disabled ? theme.colors.neutral[200] : theme.colors.brand[800];
|
|
75
|
+
});
|
|
76
|
+
const StyledItemTitles = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
77
|
+
componentId: "sc-fnpjby-4"
|
|
78
|
+
})(["display:grid;grid-template-columns:100%;width:100%;align-content:center;"]);
|
|
79
|
+
const StyledPrimaryTitle = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
80
|
+
componentId: "sc-fnpjby-5"
|
|
81
|
+
})(["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 => {
|
|
82
|
+
let {
|
|
83
|
+
disabled,
|
|
84
|
+
theme
|
|
85
|
+
} = _ref11;
|
|
86
|
+
return disabled ? theme.colors.neutral[200] : theme.colors.neutral[700];
|
|
87
|
+
}, _ref12 => {
|
|
88
|
+
let {
|
|
89
|
+
theme,
|
|
90
|
+
isDSMobile
|
|
91
|
+
} = _ref12;
|
|
92
|
+
return isDSMobile ? theme.fontWeights.regular : theme.fontWeights.regular;
|
|
93
|
+
}, _ref13 => {
|
|
94
|
+
let {
|
|
95
|
+
theme
|
|
96
|
+
} = _ref13;
|
|
97
|
+
return theme.space.xs;
|
|
98
|
+
});
|
|
99
|
+
const StyledSecondaryTitle = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
100
|
+
componentId: "sc-fnpjby-6"
|
|
101
|
+
})(["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 => {
|
|
102
|
+
let {
|
|
103
|
+
theme
|
|
104
|
+
} = _ref14;
|
|
105
|
+
return theme.fontSizes.label[200];
|
|
106
|
+
}, _ref15 => {
|
|
107
|
+
let {
|
|
108
|
+
disabled,
|
|
109
|
+
theme
|
|
110
|
+
} = _ref15;
|
|
111
|
+
return disabled ? theme.colors.neutral[200] : theme.colors.neutral[500];
|
|
112
|
+
}, _ref16 => {
|
|
113
|
+
let {
|
|
114
|
+
theme
|
|
115
|
+
} = _ref16;
|
|
116
|
+
return theme.space.xs;
|
|
117
|
+
});
|
|
118
|
+
const StyledItemCustomActions = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
119
|
+
componentId: "sc-fnpjby-7"
|
|
120
|
+
})(["display:grid;grid-auto-flow:column;grid-gap:", ";margin:0 ", ";justify-content:flex-end;"], _ref17 => {
|
|
121
|
+
let {
|
|
122
|
+
theme
|
|
123
|
+
} = _ref17;
|
|
124
|
+
return theme.space.xxs;
|
|
125
|
+
}, _ref18 => {
|
|
126
|
+
let {
|
|
127
|
+
theme
|
|
128
|
+
} = _ref18;
|
|
129
|
+
return theme.space.xs;
|
|
130
|
+
});
|
|
131
|
+
const StyledItemHeaderContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
132
|
+
componentId: "sc-fnpjby-8"
|
|
133
|
+
})(["display:grid;grid-template-columns:auto max-content;place-items:center;position:relative;&:hover{", "}"], _ref19 => {
|
|
134
|
+
let {
|
|
135
|
+
disabled,
|
|
136
|
+
theme
|
|
137
|
+
} = _ref19;
|
|
138
|
+
return !disabled ? "background: ".concat(theme.colors.brand[200], ";") : "";
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
exports.StyledItemAddon = StyledItemAddon;
|
|
142
|
+
exports.StyledItemContainer = StyledItemContainer;
|
|
143
|
+
exports.StyledItemContent = StyledItemContent;
|
|
144
|
+
exports.StyledItemCustomActions = StyledItemCustomActions;
|
|
145
|
+
exports.StyledItemHeader = StyledItemHeader;
|
|
146
|
+
exports.StyledItemHeaderContainer = StyledItemHeaderContainer;
|
|
147
|
+
exports.StyledItemTitles = StyledItemTitles;
|
|
148
|
+
exports.StyledPrimaryTitle = StyledPrimaryTitle;
|
|
149
|
+
exports.StyledSecondaryTitle = StyledSecondaryTitle;
|