@elliemae/ds-accordion 2.2.0-alpha.1 → 2.2.0-alpha.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 +50 -29
- package/cjs/DSAccordion.js.map +7 -0
- package/cjs/DSAccordionCTX.js +40 -14
- package/cjs/DSAccordionCTX.js.map +7 -0
- package/cjs/DSAccordionDatatestid.js +38 -10
- package/cjs/DSAccordionDatatestid.js.map +7 -0
- package/cjs/DSAccordionTypes.js +27 -2
- package/cjs/DSAccordionTypes.js.map +7 -0
- package/cjs/config/useAccordion.js +59 -36
- package/cjs/config/useAccordion.js.map +7 -0
- package/cjs/config/useAccordionRefs.js +46 -39
- package/cjs/config/useAccordionRefs.js.map +7 -0
- package/cjs/defaultProps.js +49 -39
- package/cjs/defaultProps.js.map +7 -0
- package/cjs/index.js +37 -14
- package/cjs/index.js.map +7 -0
- package/cjs/parts/accordionContent/AccordionContent.js +44 -35
- package/cjs/parts/accordionContent/AccordionContent.js.map +7 -0
- package/cjs/parts/accordionItem/DSAccordionItem.js +147 -174
- package/cjs/parts/accordionItem/DSAccordionItem.js.map +7 -0
- package/cjs/parts/accordionItem/styles.js +142 -128
- package/cjs/parts/accordionItem/styles.js.map +7 -0
- package/cjs/parts/accordionItem/useAccordionItem.js +52 -39
- package/cjs/parts/accordionItem/useAccordionItem.js.map +7 -0
- package/cjs/parts/accordionItem/useIsShowingEllipsis.js +42 -21
- package/cjs/parts/accordionItem/useIsShowingEllipsis.js.map +7 -0
- package/cjs/propTypes.js +53 -22
- package/cjs/propTypes.js.map +7 -0
- package/esm/DSAccordion.js +18 -16
- package/esm/DSAccordion.js.map +7 -0
- package/esm/DSAccordionCTX.js +10 -9
- package/esm/DSAccordionCTX.js.map +7 -0
- package/esm/DSAccordionDatatestid.js +9 -6
- package/esm/DSAccordionDatatestid.js.map +7 -0
- package/esm/DSAccordionTypes.js +2 -1
- package/esm/DSAccordionTypes.js.map +7 -0
- package/esm/config/useAccordion.js +25 -27
- package/esm/config/useAccordion.js.map +7 -0
- package/esm/config/useAccordionRefs.js +17 -31
- package/esm/config/useAccordionRefs.js.map +7 -0
- package/esm/defaultProps.js +21 -31
- package/esm/defaultProps.js.map +7 -0
- package/esm/index.js +8 -2
- package/esm/index.js.map +7 -0
- package/esm/parts/accordionContent/AccordionContent.js +14 -25
- package/esm/parts/accordionContent/AccordionContent.js.map +7 -0
- package/esm/parts/accordionItem/DSAccordionItem.js +114 -147
- package/esm/parts/accordionItem/DSAccordionItem.js.map +7 -0
- package/esm/parts/accordionItem/styles.js +116 -115
- package/esm/parts/accordionItem/styles.js.map +7 -0
- package/esm/parts/accordionItem/useAccordionItem.js +21 -33
- package/esm/parts/accordionItem/useAccordionItem.js.map +7 -0
- package/esm/parts/accordionItem/useIsShowingEllipsis.js +11 -15
- package/esm/parts/accordionItem/useIsShowingEllipsis.js.map +7 -0
- package/esm/propTypes.js +24 -17
- package/esm/propTypes.js.map +7 -0
- package/package.json +7 -7
|
@@ -1,35 +1,27 @@
|
|
|
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
|
-
|
|
19
|
-
import { accordionItemPropTypes } from
|
|
20
|
-
import { useAccordionItem } from
|
|
21
|
-
import { DSAccordionContext } from
|
|
22
|
-
import { DSAccordionDataTestid } from
|
|
23
|
-
import { useIsShowingEllipsis } from
|
|
24
|
-
|
|
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 => {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState, useContext, useCallback, useMemo } from "react";
|
|
3
|
+
import { describe } from "react-desc";
|
|
4
|
+
import { useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { DSButton, BUTTON_TYPE } from "@elliemae/ds-button";
|
|
6
|
+
import { DSPopperJS } from "@elliemae/ds-popperjs";
|
|
7
|
+
import { accordionItemDefaultProps } from "../../defaultProps";
|
|
8
|
+
import {
|
|
9
|
+
StyledItemAddon,
|
|
10
|
+
StyledItemContainer,
|
|
11
|
+
StyledItemContent,
|
|
12
|
+
StyledItemCustomActions,
|
|
13
|
+
StyledItemHeader,
|
|
14
|
+
StyledItemHeaderContainer,
|
|
15
|
+
StyledItemTitles,
|
|
16
|
+
StyledPrimaryTitle,
|
|
17
|
+
StyledSecondaryTitle
|
|
18
|
+
} from "./styles";
|
|
19
|
+
import { accordionItemPropTypes } from "../../propTypes";
|
|
20
|
+
import { useAccordionItem } from "./useAccordionItem";
|
|
21
|
+
import { DSAccordionContext } from "../../DSAccordionCTX";
|
|
22
|
+
import { DSAccordionDataTestid } from "../../DSAccordionDatatestid";
|
|
23
|
+
import { useIsShowingEllipsis } from "./useIsShowingEllipsis";
|
|
24
|
+
const DSAccordionItem = (props) => {
|
|
33
25
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, accordionItemDefaultProps);
|
|
34
26
|
const {
|
|
35
27
|
children,
|
|
@@ -43,151 +35,126 @@ const DSAccordionItem = props => {
|
|
|
43
35
|
dsIndex,
|
|
44
36
|
renderCustomActions
|
|
45
37
|
} = propsWithDefaults;
|
|
46
|
-
const {
|
|
47
|
-
handleOnClick,
|
|
48
|
-
handleOnKeyDown,
|
|
49
|
-
selected
|
|
50
|
-
} = useAccordionItem({
|
|
51
|
-
value,
|
|
52
|
-
disabled
|
|
53
|
-
});
|
|
38
|
+
const { handleOnClick, handleOnKeyDown, selected } = useAccordionItem({ value, disabled });
|
|
54
39
|
const {
|
|
55
40
|
allChildrenReferences,
|
|
56
41
|
actualActiveValue,
|
|
57
|
-
props: {
|
|
58
|
-
isDSMobile
|
|
59
|
-
}
|
|
42
|
+
props: { isDSMobile }
|
|
60
43
|
} = useContext(DSAccordionContext);
|
|
61
|
-
const onKeyDownWithIndex = useCallback(e => {
|
|
44
|
+
const onKeyDownWithIndex = useCallback((e) => {
|
|
62
45
|
handleOnKeyDown(e, dsIndex);
|
|
63
46
|
}, [dsIndex, handleOnKeyDown]);
|
|
64
47
|
const [showPopover, setShowPopover] = useState(false);
|
|
65
48
|
const [referenceElement, setReferenceElement] = useState();
|
|
66
49
|
const CustomActionsContent = useMemo(() => {
|
|
67
|
-
if (!isDSMobile &&
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} = _ref,
|
|
72
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
73
|
-
|
|
74
|
-
return /*#__PURE__*/jsx(DSButton, _objectSpread(_objectSpread({
|
|
75
|
-
onClick: e => {
|
|
50
|
+
if (!isDSMobile && customActions?.length > 0)
|
|
51
|
+
return /* @__PURE__ */ React2.createElement(StyledItemCustomActions, null, customActions?.map(({ onClick, id, ...rest }) => /* @__PURE__ */ React2.createElement(DSButton, {
|
|
52
|
+
key: id,
|
|
53
|
+
onClick: (e) => {
|
|
76
54
|
e.stopPropagation();
|
|
77
|
-
if (onClick)
|
|
78
|
-
|
|
79
|
-
|
|
55
|
+
if (onClick)
|
|
56
|
+
onClick(e);
|
|
57
|
+
},
|
|
58
|
+
...rest,
|
|
80
59
|
buttonType: BUTTON_TYPE.SECONDARY
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
allRefs: allChildrenReferences,
|
|
85
|
-
actualActiveValue
|
|
86
|
-
}));
|
|
60
|
+
})));
|
|
61
|
+
if (!isDSMobile && renderCustomActions)
|
|
62
|
+
return /* @__PURE__ */ React2.createElement(StyledItemCustomActions, null, renderCustomActions({ allRefs: allChildrenReferences, actualActiveValue }));
|
|
87
63
|
return null;
|
|
88
64
|
}, [actualActiveValue, allChildrenReferences, customActions, isDSMobile, renderCustomActions]);
|
|
89
|
-
const {
|
|
90
|
-
|
|
91
|
-
setElement: setPrimaryElement
|
|
92
|
-
} = useIsShowingEllipsis();
|
|
93
|
-
const {
|
|
94
|
-
isShowingEllipsis: isSecondaryShowingEllipsis,
|
|
95
|
-
setElement: setSecondaryElement
|
|
96
|
-
} = useIsShowingEllipsis();
|
|
65
|
+
const { isShowingEllipsis: isPrimaryShowingEllipsis, setElement: setPrimaryElement } = useIsShowingEllipsis();
|
|
66
|
+
const { isShowingEllipsis: isSecondaryShowingEllipsis, setElement: setSecondaryElement } = useIsShowingEllipsis();
|
|
97
67
|
const handleOnFocus = useCallback(() => setShowPopover(isPrimaryShowingEllipsis || isSecondaryShowingEllipsis), [isPrimaryShowingEllipsis, isSecondaryShowingEllipsis]);
|
|
98
68
|
const handleOnBlur = useCallback(() => setShowPopover(false), []);
|
|
99
69
|
const Titles = useMemo(() => {
|
|
100
|
-
if (isPrimaryShowingEllipsis || isSecondaryShowingEllipsis)
|
|
101
|
-
|
|
102
|
-
ref: setPrimaryElement,
|
|
103
|
-
id: "accordion_".concat(title, "id"),
|
|
104
|
-
disabled: disabled,
|
|
105
|
-
isDSMobile: isDSMobile,
|
|
106
|
-
children: title
|
|
107
|
-
}), !isDSMobile && secondaryTitle && /*#__PURE__*/jsx(StyledSecondaryTitle, {
|
|
108
|
-
ref: setSecondaryElement,
|
|
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, {
|
|
70
|
+
if (isPrimaryShowingEllipsis || isSecondaryShowingEllipsis)
|
|
71
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(StyledPrimaryTitle, {
|
|
134
72
|
ref: setPrimaryElement,
|
|
135
|
-
id:
|
|
136
|
-
disabled
|
|
137
|
-
isDSMobile
|
|
138
|
-
|
|
139
|
-
}), !isDSMobile && secondaryTitle && /*#__PURE__*/jsx(StyledSecondaryTitle, {
|
|
73
|
+
id: `accordion_${title}id`,
|
|
74
|
+
disabled,
|
|
75
|
+
isDSMobile
|
|
76
|
+
}, title), !isDSMobile && secondaryTitle && /* @__PURE__ */ React2.createElement(StyledSecondaryTitle, {
|
|
140
77
|
ref: setSecondaryElement,
|
|
141
|
-
disabled
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
78
|
+
disabled
|
|
79
|
+
}, secondaryTitle), /* @__PURE__ */ React2.createElement(DSPopperJS, {
|
|
80
|
+
referenceElement,
|
|
81
|
+
showPopover
|
|
82
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
83
|
+
style: { maxWidth: 260, padding: 8, background: "white", display: "grid", gap: 8 }
|
|
84
|
+
}, /* @__PURE__ */ React2.createElement("p", {
|
|
85
|
+
style: { margin: 0 }
|
|
86
|
+
}, title), /* @__PURE__ */ React2.createElement("p", {
|
|
87
|
+
style: { margin: 0 }
|
|
88
|
+
}, " ", secondaryTitle))));
|
|
89
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(StyledPrimaryTitle, {
|
|
90
|
+
ref: setPrimaryElement,
|
|
91
|
+
id: `accordion_${title}id`,
|
|
92
|
+
disabled,
|
|
93
|
+
isDSMobile
|
|
94
|
+
}, title), !isDSMobile && secondaryTitle && /* @__PURE__ */ React2.createElement(StyledSecondaryTitle, {
|
|
95
|
+
ref: setSecondaryElement,
|
|
96
|
+
disabled
|
|
97
|
+
}, secondaryTitle));
|
|
98
|
+
}, [
|
|
99
|
+
disabled,
|
|
100
|
+
isDSMobile,
|
|
101
|
+
isPrimaryShowingEllipsis,
|
|
102
|
+
isSecondaryShowingEllipsis,
|
|
103
|
+
referenceElement,
|
|
104
|
+
secondaryTitle,
|
|
105
|
+
setPrimaryElement,
|
|
106
|
+
setSecondaryElement,
|
|
107
|
+
showPopover,
|
|
108
|
+
title
|
|
109
|
+
]);
|
|
110
|
+
return /* @__PURE__ */ React2.createElement(StyledItemContainer, {
|
|
147
111
|
"data-testid": DSAccordionDataTestid.ITEM.CONTAINER
|
|
148
|
-
},
|
|
149
|
-
disabled
|
|
150
|
-
},
|
|
151
|
-
withCustomActions: (
|
|
112
|
+
}, /* @__PURE__ */ React2.createElement(StyledItemHeaderContainer, {
|
|
113
|
+
disabled
|
|
114
|
+
}, /* @__PURE__ */ React2.createElement(StyledItemHeader, {
|
|
115
|
+
withCustomActions: (customActions?.length > 0 || renderCustomActions !== void 0) && !isDSMobile,
|
|
152
116
|
withSecondaryTitle: secondaryTitle,
|
|
153
117
|
onClick: handleOnClick,
|
|
154
|
-
tabIndex: !disabled ? 0 :
|
|
155
|
-
disabled
|
|
118
|
+
tabIndex: !disabled ? 0 : void 0,
|
|
119
|
+
disabled,
|
|
156
120
|
"data-disabled": disabled,
|
|
157
121
|
ref: allChildrenReferences[dsIndex],
|
|
158
122
|
onKeyDown: onKeyDownWithIndex,
|
|
159
|
-
isDSMobile
|
|
123
|
+
isDSMobile,
|
|
160
124
|
"data-testid": DSAccordionDataTestid.ITEM.HEADER,
|
|
161
|
-
id:
|
|
125
|
+
id: `ds-accordion-header-${value}`,
|
|
162
126
|
"aria-expanded": selected,
|
|
163
127
|
"aria-disabled": disabled,
|
|
164
|
-
"aria-controls":
|
|
128
|
+
"aria-controls": `ds-accordion-content-${value}`,
|
|
165
129
|
onFocus: handleOnFocus,
|
|
166
|
-
onBlur: handleOnBlur
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
})]
|
|
181
|
-
}), CustomActionsContent), selected && /*#__PURE__*/_jsx2(StyledItemContent, {
|
|
130
|
+
onBlur: handleOnBlur
|
|
131
|
+
}, /* @__PURE__ */ React2.createElement(StyledItemAddon, {
|
|
132
|
+
disabled,
|
|
133
|
+
isDSMobile
|
|
134
|
+
}, selected ? /* @__PURE__ */ React2.createElement(IconOpened, {
|
|
135
|
+
isDSMobile
|
|
136
|
+
}) : /* @__PURE__ */ React2.createElement(IconClosed, {
|
|
137
|
+
isDSMobile
|
|
138
|
+
})), /* @__PURE__ */ React2.createElement(StyledItemTitles, {
|
|
139
|
+
onMouseEnter: handleOnFocus,
|
|
140
|
+
onMouseLeave: handleOnBlur,
|
|
141
|
+
isDSMobile,
|
|
142
|
+
ref: setReferenceElement
|
|
143
|
+
}, Titles)), CustomActionsContent), selected && /* @__PURE__ */ React2.createElement(StyledItemContent, {
|
|
182
144
|
"data-testid": DSAccordionDataTestid.ITEM.CONTENT,
|
|
183
|
-
"aria-labelledby":
|
|
145
|
+
"aria-labelledby": `ds-accordion-header-${value}`,
|
|
184
146
|
role: "region",
|
|
185
|
-
isDSMobile
|
|
186
|
-
id:
|
|
187
|
-
},
|
|
147
|
+
isDSMobile,
|
|
148
|
+
id: `ds-accordion-content-${value}`
|
|
149
|
+
}, children));
|
|
188
150
|
};
|
|
189
|
-
|
|
151
|
+
DSAccordionItem.propTypes = accordionItemPropTypes;
|
|
190
152
|
const DSAccordionItemWithSchema = describe(DSAccordionItem);
|
|
191
153
|
DSAccordionItemWithSchema.propTypes = accordionItemPropTypes;
|
|
192
|
-
|
|
193
|
-
export {
|
|
154
|
+
var DSAccordionItem_default = DSAccordionItem;
|
|
155
|
+
export {
|
|
156
|
+
DSAccordionItem,
|
|
157
|
+
DSAccordionItemWithSchema,
|
|
158
|
+
DSAccordionItem_default as default
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=DSAccordionItem.js.map
|
|
@@ -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", "import 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 { 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 { useIsShowingEllipsis } from './useIsShowingEllipsis';\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": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AACA;AACA;AACA;AACA;AAGA,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,wBAAwB;AAAA,IACvC,SAAS;AAAA,IACT,QAAQ;AAAA,KAER,qCAAC,iBAAD;AAAA,IAAiB;AAAA,IAAoB;AAAA,KAClC,WAAW,qCAAC,YAAD;AAAA,IAAY;AAAA,OAA6B,qCAAC,YAAD;AAAA,IAAY;AAAA,OAEnE,qCAAC,kBAAD;AAAA,IACE,cAAc;AAAA,IACd,cAAc;AAAA,IACd;AAAA,IACA,KAAK;AAAA,KAEJ,UAGJ,uBAEF,YACC,qCAAC,mBAAD;AAAA,IACE,eAAa,sBAAsB,KAAK;AAAA,IACxC,mBAAiB,uBAAuB;AAAA,IACxC,MAAK;AAAA,IACL;AAAA,IACA,IAAI,wBAAwB;AAAA,KAE3B;AAAA;AAOX,gBAAgB,YAAY;AAE5B,MAAM,4BAA4B,SAAS;AAC3C,0BAA0B,YAAY;AAGtC,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,117 +1,118 @@
|
|
|
1
|
-
import
|
|
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: grid;
|
|
11
|
+
height: ${({ withSecondaryTitle }) => withSecondaryTitle ? "48px" : "32px"};
|
|
12
|
+
grid-template-columns: ${({ withCustomActions, isDSMobile }) => withCustomActions ? "32px auto" : `${isDSMobile ? `auto 32px` : `32px auto`}`};
|
|
13
|
+
width: 100%;
|
|
14
|
+
align-items: center;
|
|
15
|
+
border: none;
|
|
16
|
+
outline: none;
|
|
17
|
+
background: none;
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
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:grid;height:", ";grid-template-columns:", ";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
|
-
withSecondaryTitle
|
|
16
|
-
} = _ref2;
|
|
17
|
-
return withSecondaryTitle ? '48px' : '32px';
|
|
18
|
-
}, _ref3 => {
|
|
19
|
-
let {
|
|
20
|
-
withCustomActions,
|
|
21
|
-
isDSMobile
|
|
22
|
-
} = _ref3;
|
|
23
|
-
return withCustomActions ? '32px auto' : "".concat(isDSMobile ? "auto 32px" : "32px auto");
|
|
24
|
-
}, _ref4 => {
|
|
25
|
-
let {
|
|
26
|
-
disabled
|
|
27
|
-
} = _ref4;
|
|
28
|
-
return disabled ? 'not-allowed' : 'pointer';
|
|
29
|
-
}, _ref5 => {
|
|
30
|
-
let {
|
|
31
|
-
isDSMobile
|
|
32
|
-
} = _ref5;
|
|
33
|
-
return isDSMobile ? "0 16px" : "0";
|
|
34
|
-
}, _ref6 => {
|
|
35
|
-
let {
|
|
36
|
-
isDSMobile
|
|
37
|
-
} = _ref6;
|
|
38
|
-
return isDSMobile ? "grid-template-areas: 'title addon';" : "";
|
|
39
|
-
}, _ref7 => {
|
|
40
|
-
let {
|
|
41
|
-
theme
|
|
42
|
-
} = _ref7;
|
|
43
|
-
return theme.colors.brand[700];
|
|
44
|
-
});
|
|
45
|
-
const StyledItemContent = /*#__PURE__*/styled.div.withConfig({
|
|
46
|
-
componentId: "sc-fnpjby-2"
|
|
47
|
-
})(["margin:", ";grid-column:1/2;"], _ref8 => {
|
|
48
|
-
let {
|
|
49
|
-
isDSMobile
|
|
50
|
-
} = _ref8;
|
|
51
|
-
return isDSMobile ? "16px 16px 24px 16px" : "16px 16px 16px 32px";
|
|
52
|
-
});
|
|
53
|
-
const StyledItemAddon = /*#__PURE__*/styled.div.withConfig({
|
|
54
|
-
componentId: "sc-fnpjby-3"
|
|
55
|
-
})(["", " height:100%;display:grid;place-items:center;& .em-ds-icon svg{fill:", ";}"], _ref9 => {
|
|
56
|
-
let {
|
|
57
|
-
isDSMobile
|
|
58
|
-
} = _ref9;
|
|
59
|
-
return !isDSMobile ? " padding: 0 8px;\n \n" : "\n grid-area: addon;\n ";
|
|
60
|
-
}, _ref10 => {
|
|
61
|
-
let {
|
|
62
|
-
disabled,
|
|
63
|
-
theme
|
|
64
|
-
} = _ref10;
|
|
65
|
-
return disabled ? theme.colors.neutral[200] : theme.colors.brand[800];
|
|
66
|
-
});
|
|
67
|
-
const StyledItemTitles = /*#__PURE__*/styled.div.withConfig({
|
|
68
|
-
componentId: "sc-fnpjby-4"
|
|
69
|
-
})(["display:grid;grid-template-columns:100%;align-content:center;", ""], _ref11 => {
|
|
70
|
-
let {
|
|
71
|
-
isDSMobile
|
|
72
|
-
} = _ref11;
|
|
73
|
-
return isDSMobile ? "grid-area: title;" : "";
|
|
74
|
-
});
|
|
75
|
-
const StyledPrimaryTitle = /*#__PURE__*/styled.div.withConfig({
|
|
76
|
-
componentId: "sc-fnpjby-5"
|
|
77
|
-
})(["margin:0;font-size:16px;color:", ";font-weight:", ";text-overflow:ellipsis;overflow:hidden;height:16px;width:100%;text-align:left;display:block;white-space:nowrap;"], _ref12 => {
|
|
78
|
-
let {
|
|
79
|
-
disabled,
|
|
80
|
-
theme
|
|
81
|
-
} = _ref12;
|
|
82
|
-
return disabled ? theme.colors.neutral[200] : theme.colors.neutral[700];
|
|
83
|
-
}, _ref13 => {
|
|
84
|
-
let {
|
|
85
|
-
theme,
|
|
86
|
-
isDSMobile
|
|
87
|
-
} = _ref13;
|
|
88
|
-
return isDSMobile ? theme.fontWeights.regular : theme.fontWeights.regular;
|
|
89
|
-
});
|
|
90
|
-
const StyledSecondaryTitle = /*#__PURE__*/styled.span.withConfig({
|
|
91
|
-
componentId: "sc-fnpjby-6"
|
|
92
|
-
})(["margin:0;font-size:", ";text-align:left;color:", ";text-overflow:ellipsis;overflow:hidden;height:16px;width:100%;text-align:left;display:block;white-space:nowrap;"], _ref14 => {
|
|
93
|
-
let {
|
|
94
|
-
theme
|
|
95
|
-
} = _ref14;
|
|
96
|
-
return theme.fontSizes.label[200];
|
|
97
|
-
}, _ref15 => {
|
|
98
|
-
let {
|
|
99
|
-
disabled,
|
|
100
|
-
theme
|
|
101
|
-
} = _ref15;
|
|
102
|
-
return disabled ? theme.colors.neutral[200] : theme.colors.neutral[500];
|
|
103
|
-
});
|
|
104
|
-
const StyledItemCustomActions = /*#__PURE__*/styled.div.withConfig({
|
|
105
|
-
componentId: "sc-fnpjby-7"
|
|
106
|
-
})(["display:grid;grid-auto-flow:column;grid-gap:8px;margin:0 16px;justify-content:flex-end;"]);
|
|
107
|
-
const StyledItemHeaderContainer = /*#__PURE__*/styled.div.withConfig({
|
|
108
|
-
componentId: "sc-fnpjby-8"
|
|
109
|
-
})(["display:grid;grid-template-columns:auto max-content;place-items:center;position:relative;&:hover{", ";}"], _ref16 => {
|
|
110
|
-
let {
|
|
111
|
-
disabled,
|
|
112
|
-
theme
|
|
113
|
-
} = _ref16;
|
|
114
|
-
return !disabled ? "background: ".concat(theme.colors.brand[200]) : "";
|
|
115
|
-
});
|
|
19
|
+
&:hover {
|
|
20
|
+
cursor: ${({ disabled }) => disabled ? "not-allowed" : "pointer"};
|
|
21
|
+
}
|
|
116
22
|
|
|
117
|
-
|
|
23
|
+
padding: ${({ isDSMobile }) => isDSMobile ? `0 16px` : `0`};
|
|
24
|
+
|
|
25
|
+
${({ isDSMobile }) => isDSMobile ? `grid-template-areas: 'title addon';` : ``}
|
|
26
|
+
|
|
27
|
+
&:focus {
|
|
28
|
+
&:after {
|
|
29
|
+
position: absolute;
|
|
30
|
+
content: '';
|
|
31
|
+
left: 0;
|
|
32
|
+
top: 0;
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
border-radius: 2px;
|
|
36
|
+
border: 2px solid ${({ theme }) => theme.colors.brand[700]};
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const StyledItemContent = styled.div`
|
|
42
|
+
margin: ${({ isDSMobile }) => isDSMobile ? `16px 16px 24px 16px` : `16px 16px 16px 32px`};
|
|
43
|
+
grid-column: 1/2;
|
|
44
|
+
`;
|
|
45
|
+
const StyledItemAddon = styled.div`
|
|
46
|
+
${({ isDSMobile }) => !isDSMobile ? ` padding: 0 8px;
|
|
47
|
+
|
|
48
|
+
` : `
|
|
49
|
+
grid-area: addon;
|
|
50
|
+
`}
|
|
51
|
+
height: 100%;
|
|
52
|
+
display: grid;
|
|
53
|
+
place-items: center;
|
|
54
|
+
|
|
55
|
+
& .em-ds-icon svg {
|
|
56
|
+
fill: ${({ disabled, theme }) => disabled ? theme.colors.neutral[200] : theme.colors.brand[800]};
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
const StyledItemTitles = styled.div`
|
|
60
|
+
display: grid;
|
|
61
|
+
grid-template-columns: 100%;
|
|
62
|
+
align-content: center;
|
|
63
|
+
${({ isDSMobile }) => isDSMobile ? `grid-area: title;` : ``}
|
|
64
|
+
`;
|
|
65
|
+
const StyledPrimaryTitle = styled.div`
|
|
66
|
+
margin: 0;
|
|
67
|
+
font-size: 16px;
|
|
68
|
+
color: ${({ disabled, theme }) => disabled ? theme.colors.neutral[200] : theme.colors.neutral[700]};
|
|
69
|
+
font-weight: ${({ theme, isDSMobile }) => isDSMobile ? theme.fontWeights.regular : theme.fontWeights.regular};
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
height: 16px;
|
|
73
|
+
width: 100%;
|
|
74
|
+
text-align: left;
|
|
75
|
+
display: block;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
`;
|
|
78
|
+
const StyledSecondaryTitle = styled.span`
|
|
79
|
+
margin: 0;
|
|
80
|
+
font-size: ${({ theme }) => theme.fontSizes.label[200]};
|
|
81
|
+
text-align: left;
|
|
82
|
+
color: ${({ disabled, theme }) => disabled ? theme.colors.neutral[200] : theme.colors.neutral[500]};
|
|
83
|
+
text-overflow: ellipsis;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
height: 16px;
|
|
86
|
+
width: 100%;
|
|
87
|
+
text-align: left;
|
|
88
|
+
display: block;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
`;
|
|
91
|
+
const StyledItemCustomActions = styled.div`
|
|
92
|
+
display: grid;
|
|
93
|
+
grid-auto-flow: column;
|
|
94
|
+
grid-gap: 8px;
|
|
95
|
+
margin: 0 16px;
|
|
96
|
+
justify-content: flex-end;
|
|
97
|
+
`;
|
|
98
|
+
const StyledItemHeaderContainer = styled.div`
|
|
99
|
+
display: grid;
|
|
100
|
+
grid-template-columns: auto max-content;
|
|
101
|
+
place-items: center;
|
|
102
|
+
position: relative;
|
|
103
|
+
&:hover {
|
|
104
|
+
${({ disabled, theme }) => !disabled ? `background: ${theme.colors.brand[200]}` : ``};
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
export {
|
|
108
|
+
StyledItemAddon,
|
|
109
|
+
StyledItemContainer,
|
|
110
|
+
StyledItemContent,
|
|
111
|
+
StyledItemCustomActions,
|
|
112
|
+
StyledItemHeader,
|
|
113
|
+
StyledItemHeaderContainer,
|
|
114
|
+
StyledItemTitles,
|
|
115
|
+
StyledPrimaryTitle,
|
|
116
|
+
StyledSecondaryTitle
|
|
117
|
+
};
|
|
118
|
+
//# 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} 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: grid;\n height: ${({ withSecondaryTitle }) => (withSecondaryTitle ? '48px' : '32px')};\n grid-template-columns: ${({ withCustomActions, isDSMobile }) =>\n withCustomActions ? '32px auto' : `${isDSMobile ? `auto 32px` : `32px auto`}`};\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 ? `grid-template-areas: 'title addon';` : ``)}\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 ${({ isDSMobile }) =>\n !isDSMobile\n ? ` padding: 0 8px;\n \n`\n : `\n grid-area: addon;\n `}\n height: 100%;\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 align-content: center;\n ${({ isDSMobile }) => (isDSMobile ? `grid-area: title;` : ``)}\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: 16px;\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: 16px;\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: 8px;\n margin: 0 16px;\n justify-content: flex-end;\n`;\n\nexport const StyledItemHeaderContainer = styled.div`\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;AAUO,MAAM,sBAAsB,OAAO;AAAA;AAAA;AAAA,6BAGb,CAAC,EAAE,YAAY,MAAM,OAAO,QAAQ;AAAA;AAAA;AAI1D,MAAM,mBAAmB,OAAO;AAAA;AAAA,YAE3B,CAAC,EAAE,yBAA0B,qBAAqB,SAAS;AAAA,2BAC5C,CAAC,EAAE,mBAAmB,iBAC7C,oBAAoB,cAAc,GAAG,aAAa,cAAc;AAAA;AAAA;AAAA;AAA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQvC,MAAM,4BAA4B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAM1C,CAAC,EAAE,UAAU,YAAa,CAAC,WAAW,eAAe,MAAM,OAAO,MAAM,SAAS;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,42 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
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)
|
|
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 ===
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
34
|
+
export {
|
|
35
|
+
useAccordionItem
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=useAccordionItem.js.map
|