carbon-react 94.6.0 → 94.6.1
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.
|
@@ -19,8 +19,6 @@ var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/e
|
|
|
19
19
|
|
|
20
20
|
var _accordion = require("./accordion.style");
|
|
21
21
|
|
|
22
|
-
var _button = _interopRequireDefault(require("../button"));
|
|
23
|
-
|
|
24
22
|
var _validations = _interopRequireDefault(require("../../__internal__/validations"));
|
|
25
23
|
|
|
26
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -71,7 +69,10 @@ const Accordion = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
71
69
|
setContentHeight(accordionContent.current.scrollHeight);
|
|
72
70
|
}, [isExpanded, children]);
|
|
73
71
|
const toggleAccordion = (0, _react.useCallback)(ev => {
|
|
74
|
-
if (!isControlled)
|
|
72
|
+
if (!isControlled) {
|
|
73
|
+
setIsExpandedInternal(!isExpanded);
|
|
74
|
+
}
|
|
75
|
+
|
|
75
76
|
if (onChange) onChange(ev, !isExpanded);
|
|
76
77
|
}, [isControlled, isExpanded, onChange]);
|
|
77
78
|
const handleKeyDown = (0, _react.useCallback)(ev => {
|
|
@@ -88,6 +89,9 @@ const Accordion = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
88
89
|
const headerId = `AccordionHeader_${guid.current}`;
|
|
89
90
|
const contentId = `AccordionContent_${guid.current}`;
|
|
90
91
|
const showValidationIcon = !!(error || warning || info);
|
|
92
|
+
|
|
93
|
+
const getTitle = () => isExpanded ? openTitle || title : title;
|
|
94
|
+
|
|
91
95
|
return /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContainer, _extends({
|
|
92
96
|
id: accordionId,
|
|
93
97
|
"data-component": "accordion",
|
|
@@ -100,39 +104,39 @@ const Accordion = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
100
104
|
id: headerId,
|
|
101
105
|
"aria-expanded": isExpanded,
|
|
102
106
|
"aria-controls": contentId,
|
|
103
|
-
onClick:
|
|
104
|
-
onKeyDown:
|
|
107
|
+
onClick: toggleAccordion,
|
|
108
|
+
onKeyDown: handleKeyDown,
|
|
109
|
+
tabIndex: 0,
|
|
105
110
|
iconAlign: iconAlign,
|
|
106
111
|
ref: ref,
|
|
107
|
-
tabIndex: buttonHeading ? "-1" : "0",
|
|
108
112
|
size: size,
|
|
109
113
|
isExpanded: isExpanded,
|
|
110
114
|
buttonHeading: buttonHeading,
|
|
111
|
-
buttonWidth: buttonWidth
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, isExpanded ? openTitle || title : title), !buttonHeading && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionHeadingsContainer, {
|
|
115
|
+
buttonWidth: buttonWidth,
|
|
116
|
+
hasButtonProps: buttonHeading && headerSpacing
|
|
117
|
+
}, buttonHeading && {
|
|
118
|
+
role: "button",
|
|
119
|
+
p: 0
|
|
120
|
+
}, headerSpacing), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionHeadingsContainer, {
|
|
118
121
|
"data-element": "accordion-headings-container",
|
|
119
|
-
hasValidationIcon: showValidationIcon
|
|
120
|
-
|
|
122
|
+
hasValidationIcon: showValidationIcon,
|
|
123
|
+
buttonHeading: buttonHeading
|
|
124
|
+
}, !buttonHeading && typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionTitle, {
|
|
121
125
|
"data-element": "accordion-title",
|
|
122
126
|
size: size
|
|
123
|
-
}, title) :
|
|
127
|
+
}, title) : getTitle(), !buttonHeading && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showValidationIcon && /*#__PURE__*/_react.default.createElement(_validations.default, {
|
|
124
128
|
error: error,
|
|
125
129
|
warning: warning,
|
|
126
130
|
info: info,
|
|
127
131
|
tooltipPosition: "top",
|
|
128
132
|
tabIndex: 0,
|
|
129
133
|
ml: 1
|
|
130
|
-
}), subTitle && size === "large" && /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionSubTitle, null, subTitle)), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionIcon, {
|
|
134
|
+
}), subTitle && size === "large" && /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionSubTitle, null, subTitle))), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionIcon, {
|
|
131
135
|
"data-element": "accordion-icon",
|
|
132
136
|
type: iconType,
|
|
133
137
|
isExpanded: isExpanded,
|
|
134
138
|
iconAlign: iconAlign
|
|
135
|
-
}))
|
|
139
|
+
})), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContentContainer, {
|
|
136
140
|
isExpanded: isExpanded,
|
|
137
141
|
maxHeight: contentHeight
|
|
138
142
|
}, /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContent, {
|
|
@@ -22,11 +22,11 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
22
22
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
23
|
|
|
24
24
|
const StyledAccordionGroup = _styledComponents.default.div`
|
|
25
|
-
${_styledSystem.margin}
|
|
25
|
+
${_styledSystem.margin}
|
|
26
26
|
`;
|
|
27
27
|
exports.StyledAccordionGroup = StyledAccordionGroup;
|
|
28
28
|
const StyledAccordionContainer = _styledComponents.default.div`
|
|
29
|
-
${_styledSystem.space}
|
|
29
|
+
${_styledSystem.space}
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: ${({
|
|
32
32
|
buttonHeading
|
|
@@ -48,18 +48,18 @@ const StyledAccordionContainer = _styledComponents.default.div`
|
|
|
48
48
|
theme
|
|
49
49
|
}) => (0, _styledComponents.css)`
|
|
50
50
|
border: 1px solid ${theme.accordion.border};
|
|
51
|
-
`}
|
|
51
|
+
`}
|
|
52
52
|
${({
|
|
53
53
|
borders
|
|
54
54
|
}) => borders === "default" && (0, _styledComponents.css)`
|
|
55
55
|
border-left: none;
|
|
56
56
|
border-right: none;
|
|
57
|
-
`}
|
|
57
|
+
`}
|
|
58
58
|
${({
|
|
59
59
|
borders
|
|
60
60
|
}) => borders === "none" && (0, _styledComponents.css)`
|
|
61
61
|
border: none;
|
|
62
|
-
`}
|
|
62
|
+
`}
|
|
63
63
|
|
|
64
64
|
& + & {
|
|
65
65
|
margin-top: -1px;
|
|
@@ -103,28 +103,29 @@ const StyledAccordionIcon = (0, _styledComponents.default)(_icon.default)`
|
|
|
103
103
|
`;
|
|
104
104
|
exports.StyledAccordionIcon = StyledAccordionIcon;
|
|
105
105
|
const StyledAccordionHeadingsContainer = _styledComponents.default.div`
|
|
106
|
-
display: grid;
|
|
107
106
|
${({
|
|
107
|
+
buttonHeading,
|
|
108
108
|
hasValidationIcon
|
|
109
|
-
}) =>
|
|
110
|
-
|
|
109
|
+
}) => !buttonHeading && (0, _styledComponents.css)`
|
|
110
|
+
display: grid;
|
|
111
|
+
${hasValidationIcon && (0, _styledComponents.css)`
|
|
112
|
+
grid-template-columns: min-content auto;
|
|
113
|
+
|
|
114
|
+
${StyledAccordionSubTitle} {
|
|
115
|
+
grid-column: span 3;
|
|
116
|
+
}
|
|
117
|
+
`}
|
|
111
118
|
|
|
112
|
-
${
|
|
113
|
-
grid-
|
|
114
|
-
}
|
|
115
|
-
`}
|
|
119
|
+
${!hasValidationIcon && (0, _styledComponents.css)`
|
|
120
|
+
grid-template-rows: auto auto;
|
|
121
|
+
`}
|
|
116
122
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
${_validationIcon.default} {
|
|
124
|
+
height: 20px;
|
|
125
|
+
position: relative;
|
|
126
|
+
top: 2px;
|
|
127
|
+
}
|
|
121
128
|
`}
|
|
122
|
-
|
|
123
|
-
${_validationIcon.default} {
|
|
124
|
-
height: 20px;
|
|
125
|
-
position: relative;
|
|
126
|
-
top: 2px;
|
|
127
|
-
}
|
|
128
129
|
`;
|
|
129
130
|
exports.StyledAccordionHeadingsContainer = StyledAccordionHeadingsContainer;
|
|
130
131
|
const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
@@ -132,13 +133,12 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
132
133
|
buttonHeading,
|
|
133
134
|
buttonWidth,
|
|
134
135
|
iconAlign,
|
|
135
|
-
isExpanded,
|
|
136
136
|
size,
|
|
137
|
-
theme
|
|
137
|
+
theme,
|
|
138
|
+
hasButtonProps
|
|
138
139
|
}) => (0, _styledComponents.css)`
|
|
139
140
|
padding: ${size === "small" ? theme.spacing * 2 : theme.spacing * 3}px;
|
|
140
|
-
${_styledSystem.space}
|
|
141
|
-
${buttonHeading && "padding: 0"}
|
|
141
|
+
${_styledSystem.space}
|
|
142
142
|
display: flex;
|
|
143
143
|
align-items: center;
|
|
144
144
|
justify-content: space-between;
|
|
@@ -152,7 +152,7 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
152
152
|
z-index: 1;
|
|
153
153
|
|
|
154
154
|
&:focus {
|
|
155
|
-
outline: ${buttonHeading ? "
|
|
155
|
+
outline: ${buttonHeading ? "3px" : "2px"} solid ${theme.colors.focus};
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
${!buttonHeading && (0, _styledComponents.css)`
|
|
@@ -161,24 +161,40 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
161
161
|
}
|
|
162
162
|
`}
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
${buttonHeading && (0, _styledComponents.css)`
|
|
165
|
+
box-sizing: border-box;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
text-decoration: none;
|
|
168
|
+
font-size: ${theme.text.size};
|
|
169
|
+
min-height: ${theme.spacing * 5}px;
|
|
170
|
+
|
|
171
|
+
color: ${theme.colors.primary};
|
|
172
|
+
|
|
173
|
+
${!hasButtonProps && (0, _styledComponents.css)`
|
|
174
|
+
${StyledAccordionHeadingsContainer} {
|
|
175
|
+
margin-left: ${iconAlign === "right" ? "64px" : "32px"};
|
|
176
|
+
}
|
|
168
177
|
`}
|
|
169
|
-
}
|
|
170
178
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
${StyledAccordionIcon} {
|
|
180
|
+
color: ${theme.colors.primary};
|
|
181
|
+
${!hasButtonProps && (0, _styledComponents.css)`
|
|
182
|
+
position: relative;
|
|
183
|
+
${iconAlign}: 16px;
|
|
184
|
+
`}
|
|
185
|
+
}
|
|
175
186
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
&:hover {
|
|
188
|
+
color: ${theme.colors.secondary};
|
|
189
|
+
${StyledAccordionIcon} {
|
|
190
|
+
color: ${theme.colors.secondary};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
${buttonWidth && (0, _styledComponents.css)`
|
|
195
|
+
width: ${buttonWidth}px;
|
|
196
|
+
`}
|
|
197
|
+
`}
|
|
182
198
|
`}
|
|
183
199
|
`;
|
|
184
200
|
exports.StyledAccordionTitleContainer = StyledAccordionTitleContainer;
|