@lumx/react 3.9.4 → 3.9.5
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/index.js +7 -27
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/chip/Chip.test.tsx +15 -0
- package/src/components/chip/Chip.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +32 -2
- package/src/components/expansion-panel/ExpansionPanel.tsx +6 -30
package/index.js
CHANGED
|
@@ -354,6 +354,7 @@ const CSS_PREFIX = 'lumx';
|
|
|
354
354
|
* you need to update their scss counterpart as well
|
|
355
355
|
*/
|
|
356
356
|
const DIALOG_TRANSITION_DURATION = 400;
|
|
357
|
+
const EXPANSION_PANEL_TRANSITION_DURATION = 400;
|
|
357
358
|
const NOTIFICATION_TRANSITION_DURATION = 200;
|
|
358
359
|
|
|
359
360
|
/**
|
|
@@ -5701,6 +5702,9 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
5701
5702
|
const handleOnAfterClick = useStopPropagation(onAfterClick);
|
|
5702
5703
|
const handleKeyDown = evt => {
|
|
5703
5704
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(evt);
|
|
5705
|
+
if (hasOnClick) {
|
|
5706
|
+
onEnterPressed(onClick)(evt);
|
|
5707
|
+
}
|
|
5704
5708
|
};
|
|
5705
5709
|
return (
|
|
5706
5710
|
/*#__PURE__*/
|
|
@@ -7172,7 +7176,6 @@ const ExpansionPanel = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7172
7176
|
toggleButtonProps
|
|
7173
7177
|
} = props,
|
|
7174
7178
|
forwardedProps = _objectWithoutProperties(props, _excluded$12);
|
|
7175
|
-
const [isChildrenVisible, setIsChildrenVisible] = useState(isOpen);
|
|
7176
7179
|
const children = Children.toArray(anyChildren);
|
|
7177
7180
|
|
|
7178
7181
|
// Partition children by types.
|
|
@@ -7184,34 +7187,15 @@ const ExpansionPanel = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7184
7187
|
className: `${CLASSNAME$Z}__label`
|
|
7185
7188
|
}, label);
|
|
7186
7189
|
const toggleOpen = event => {
|
|
7187
|
-
var _WINDOW$matchMedia, _WINDOW$matchMedia$ca;
|
|
7188
|
-
const hasReducedMotionEnabled = WINDOW === null || WINDOW === void 0 ? void 0 : (_WINDOW$matchMedia = WINDOW.matchMedia) === null || _WINDOW$matchMedia === void 0 ? void 0 : (_WINDOW$matchMedia$ca = _WINDOW$matchMedia.call(WINDOW, '(prefers-reduced-motion: reduce)')) === null || _WINDOW$matchMedia$ca === void 0 ? void 0 : _WINDOW$matchMedia$ca.matches;
|
|
7189
7190
|
const shouldOpen = !isOpen;
|
|
7190
7191
|
if (isFunction(onOpen) && shouldOpen) {
|
|
7191
7192
|
onOpen(event);
|
|
7192
|
-
// On open, we immediately show children
|
|
7193
|
-
setIsChildrenVisible(true);
|
|
7194
7193
|
}
|
|
7195
7194
|
if (isFunction(onClose) && !shouldOpen) {
|
|
7196
7195
|
onClose(event);
|
|
7197
|
-
/**
|
|
7198
|
-
* On close, we only show children immediately if reduced motion is enabled
|
|
7199
|
-
* When disabled, the children will be hidden via the `onTransitionEnd` prop.
|
|
7200
|
-
*/
|
|
7201
|
-
if (hasReducedMotionEnabled) {
|
|
7202
|
-
setIsChildrenVisible(false);
|
|
7203
|
-
}
|
|
7204
7196
|
}
|
|
7205
7197
|
if (isFunction(onToggleOpen)) {
|
|
7206
7198
|
onToggleOpen(shouldOpen, event);
|
|
7207
|
-
/**
|
|
7208
|
-
* On toggle, we forward the show state if
|
|
7209
|
-
* * the toggle will open the expansion panel
|
|
7210
|
-
* * reduced motion is enabled. When disabled, the children will be hidden via the `onTransitionEnd` prop.
|
|
7211
|
-
* */
|
|
7212
|
-
if (shouldOpen || hasReducedMotionEnabled) {
|
|
7213
|
-
setIsChildrenVisible(shouldOpen);
|
|
7214
|
-
}
|
|
7215
7199
|
}
|
|
7216
7200
|
};
|
|
7217
7201
|
const color = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
|
|
@@ -7227,6 +7211,9 @@ const ExpansionPanel = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7227
7211
|
}));
|
|
7228
7212
|
const wrapperRef = useRef(null);
|
|
7229
7213
|
|
|
7214
|
+
/** Hide the children at the end of the transition */
|
|
7215
|
+
const isChildrenVisible = useTransitionVisibility(wrapperRef, !!isOpen, EXPANSION_PANEL_TRANSITION_DURATION);
|
|
7216
|
+
|
|
7230
7217
|
// Switch max height on/off to activate the CSS transition (updates when children changes).
|
|
7231
7218
|
const [maxHeight, setMaxHeight] = useState('0');
|
|
7232
7219
|
useEffect(() => {
|
|
@@ -7256,13 +7243,6 @@ const ExpansionPanel = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7256
7243
|
style: {
|
|
7257
7244
|
maxHeight
|
|
7258
7245
|
}
|
|
7259
|
-
// At the end of the closing transition, remove the children from the DOM
|
|
7260
|
-
,
|
|
7261
|
-
onTransitionEnd: () => {
|
|
7262
|
-
if (!isOpen) {
|
|
7263
|
-
setIsChildrenVisible(false);
|
|
7264
|
-
}
|
|
7265
|
-
}
|
|
7266
7246
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7267
7247
|
className: `${CLASSNAME$Z}__container`,
|
|
7268
7248
|
ref: wrapperRef
|