@conveyorhq/arrow-ds 1.143.0 → 1.143.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.
package/package.json
CHANGED
|
@@ -147,6 +147,7 @@ const AccordionIcon = ({ className, direction = "down", color, disabled = false,
|
|
|
147
147
|
};
|
|
148
148
|
exports.AccordionIcon = AccordionIcon;
|
|
149
149
|
const AccordionContent = ({ children, maxHeight, style, className, scrollClassName, ...rest }) => {
|
|
150
|
+
const { disableAnimation } = (0, context_1.useAccordionGroupContext)();
|
|
150
151
|
const { buttonId, contentId, defaultIsOpen, isOpen, } = (0, context_1.useAccordionItemContext)();
|
|
151
152
|
const [childrenRef, setChildrenRef] = react_1.default.useState({ current: null });
|
|
152
153
|
const onRefChange = react_1.default.useCallback((node) => {
|
|
@@ -155,18 +156,20 @@ const AccordionContent = ({ children, maxHeight, style, className, scrollClassNa
|
|
|
155
156
|
}
|
|
156
157
|
}, []);
|
|
157
158
|
const [enableTransition, setEnableTransition] = react_1.default.useState(!defaultIsOpen);
|
|
158
|
-
const { height
|
|
159
|
-
const
|
|
160
|
-
height: isOpen ?
|
|
161
|
-
|
|
159
|
+
const { height } = (0, component_size_1.default)(childrenRef);
|
|
160
|
+
const props = (0, web_1.useSpring)({
|
|
161
|
+
height: isOpen ? height : 0,
|
|
162
|
+
opacity: isOpen ? 1 : 0,
|
|
163
|
+
config: { mass: 2, tension: 400, friction: 50 },
|
|
162
164
|
onRest: () => {
|
|
163
165
|
if (defaultIsOpen && isOpen) {
|
|
164
166
|
setEnableTransition(true);
|
|
165
167
|
}
|
|
166
168
|
},
|
|
169
|
+
immediate: disableAnimation || !enableTransition,
|
|
167
170
|
});
|
|
168
|
-
return (react_1.default.createElement(web_1.animated.div, { className: (0, classnames_1.default)("overflow-hidden box-content", className), style: { ...style,
|
|
169
|
-
react_1.default.createElement(Box_1.Box, { ref: onRefChange, className: (0, classnames_1.default)(maxHeight && "overflow-y-auto"), style: maxHeight ? { maxHeight } : undefined }, children)));
|
|
171
|
+
return (react_1.default.createElement(web_1.animated.div, { className: (0, classnames_1.default)("overflow-hidden box-content", className), style: { ...style, ...props }, "aria-labelledby": buttonId, id: contentId, role: "region", ...rest },
|
|
172
|
+
react_1.default.createElement(Box_1.Box, { ref: onRefChange, className: (0, classnames_1.default)(maxHeight && "overflow-y-auto", scrollClassName), style: maxHeight ? { maxHeight } : undefined }, children)));
|
|
170
173
|
};
|
|
171
174
|
exports.AccordionContent = AccordionContent;
|
|
172
175
|
const Accordion = (props) => {
|
|
@@ -308,7 +308,7 @@ export const AccordionContent = ({
|
|
|
308
308
|
scrollClassName,
|
|
309
309
|
...rest
|
|
310
310
|
}: AccordionContentProps) => {
|
|
311
|
-
|
|
311
|
+
const { disableAnimation } = useAccordionGroupContext();
|
|
312
312
|
const {
|
|
313
313
|
buttonId,
|
|
314
314
|
contentId,
|
|
@@ -328,20 +328,24 @@ export const AccordionContent = ({
|
|
|
328
328
|
const [enableTransition, setEnableTransition] = React.useState(
|
|
329
329
|
!defaultIsOpen,
|
|
330
330
|
);
|
|
331
|
-
|
|
332
|
-
const { height } =
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
|
|
332
|
+
const { height } = useComponentSize(childrenRef);
|
|
333
|
+
const props = useSpring({
|
|
334
|
+
height: isOpen ? height : 0,
|
|
335
|
+
opacity: isOpen ? 1 : 0,
|
|
336
|
+
config: { mass: 2, tension: 400, friction: 50 },
|
|
335
337
|
onRest: () => {
|
|
336
338
|
if (defaultIsOpen && isOpen) {
|
|
337
339
|
setEnableTransition(true);
|
|
338
340
|
}
|
|
339
341
|
},
|
|
342
|
+
immediate: disableAnimation || !enableTransition,
|
|
340
343
|
});
|
|
344
|
+
|
|
341
345
|
return (
|
|
342
346
|
<animated.div
|
|
343
347
|
className={classNames("overflow-hidden box-content", className)}
|
|
344
|
-
style={{ ...style,
|
|
348
|
+
style={{ ...style, ...props }}
|
|
345
349
|
aria-labelledby={buttonId}
|
|
346
350
|
id={contentId}
|
|
347
351
|
role="region"
|
|
@@ -349,7 +353,7 @@ export const AccordionContent = ({
|
|
|
349
353
|
>
|
|
350
354
|
<Box
|
|
351
355
|
ref={onRefChange}
|
|
352
|
-
className={classNames(maxHeight && "overflow-y-auto")}
|
|
356
|
+
className={classNames(maxHeight && "overflow-y-auto", scrollClassName)}
|
|
353
357
|
style={maxHeight ? { maxHeight } : undefined}
|
|
354
358
|
>
|
|
355
359
|
{children}
|