@lumx/react 3.13.3-alpha.1 → 3.13.3-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/index.js +6 -20
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/expansion-panel/ExpansionPanel.tsx +8 -21
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@lumx/core": "^3.13.3-alpha.
|
|
10
|
-
"@lumx/icons": "^3.13.3-alpha.
|
|
9
|
+
"@lumx/core": "^3.13.3-alpha.2",
|
|
10
|
+
"@lumx/icons": "^3.13.3-alpha.2",
|
|
11
11
|
"@popperjs/core": "^2.5.4",
|
|
12
12
|
"body-scroll-lock": "^3.1.5",
|
|
13
13
|
"classnames": "^2.3.2",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"build:storybook": "storybook build"
|
|
111
111
|
},
|
|
112
112
|
"sideEffects": false,
|
|
113
|
-
"version": "3.13.3-alpha.
|
|
113
|
+
"version": "3.13.3-alpha.2"
|
|
114
114
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import React, { Children, PropsWithChildren, ReactNode,
|
|
1
|
+
import React, { Children, PropsWithChildren, ReactNode, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
|
|
6
6
|
|
|
7
|
-
import get from 'lodash/get';
|
|
8
7
|
import isEmpty from 'lodash/isEmpty';
|
|
9
|
-
import isFunction from 'lodash/isFunction';
|
|
10
8
|
|
|
11
9
|
import { ColorPalette, DragHandle, Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
|
|
12
10
|
import { GenericProps, HasTheme, isComponent } from '@lumx/react/utils/type';
|
|
@@ -101,13 +99,13 @@ export const ExpansionPanel = forwardRef<ExpansionPanelProps, HTMLDivElement>((p
|
|
|
101
99
|
const toggleOpen = (event: React.MouseEvent) => {
|
|
102
100
|
const shouldOpen = !isOpen;
|
|
103
101
|
|
|
104
|
-
if (
|
|
102
|
+
if (onOpen && shouldOpen) {
|
|
105
103
|
onOpen(event);
|
|
106
104
|
}
|
|
107
|
-
if (
|
|
105
|
+
if (onClose && !shouldOpen) {
|
|
108
106
|
onClose(event);
|
|
109
107
|
}
|
|
110
|
-
if (
|
|
108
|
+
if (onToggleOpen) {
|
|
111
109
|
onToggleOpen(shouldOpen, event);
|
|
112
110
|
}
|
|
113
111
|
};
|
|
@@ -133,17 +131,6 @@ export const ExpansionPanel = forwardRef<ExpansionPanelProps, HTMLDivElement>((p
|
|
|
133
131
|
/** Hide the children at the end of the transition */
|
|
134
132
|
const isChildrenVisible = useTransitionVisibility(wrapperRef, !!isOpen, EXPANSION_PANEL_TRANSITION_DURATION);
|
|
135
133
|
|
|
136
|
-
// Switch max height on/off to activate the CSS transition (updates when children changes).
|
|
137
|
-
const [maxHeight, setMaxHeight] = useState<string | undefined>('0');
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
const height = isOpen ? get(wrapperRef.current, 'offsetHeight', 0) : 0;
|
|
140
|
-
setMaxHeight(`${height}px`);
|
|
141
|
-
}, [isOpen]);
|
|
142
|
-
|
|
143
|
-
const onTransitionEnd = React.useCallback(() => {
|
|
144
|
-
setMaxHeight(undefined);
|
|
145
|
-
}, []);
|
|
146
|
-
|
|
147
134
|
return (
|
|
148
135
|
<section ref={ref} {...forwardedProps} className={rootClassName}>
|
|
149
136
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
|
|
@@ -165,15 +152,15 @@ export const ExpansionPanel = forwardRef<ExpansionPanelProps, HTMLDivElement>((p
|
|
|
165
152
|
</div>
|
|
166
153
|
</header>
|
|
167
154
|
|
|
168
|
-
{
|
|
169
|
-
|
|
155
|
+
<div className={`${CLASSNAME}__wrapper`}>
|
|
156
|
+
{(isOpen || isChildrenVisible) && (
|
|
170
157
|
<div className={`${CLASSNAME}__container`} ref={wrapperRef}>
|
|
171
158
|
<div className={`${CLASSNAME}__content`}>{content}</div>
|
|
172
159
|
|
|
173
160
|
{footer && <div className={`${CLASSNAME}__footer`}>{footer}</div>}
|
|
174
161
|
</div>
|
|
175
|
-
|
|
176
|
-
|
|
162
|
+
)}
|
|
163
|
+
</div>
|
|
177
164
|
</section>
|
|
178
165
|
);
|
|
179
166
|
});
|