@lumx/react 3.11.1-alpha.2 → 3.11.1-alpha.4

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
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^3.11.1-alpha.2",
10
- "@lumx/icons": "^3.11.1-alpha.2",
9
+ "@lumx/core": "^3.11.1-alpha.4",
10
+ "@lumx/icons": "^3.11.1-alpha.4",
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.11.1-alpha.2"
113
+ "version": "3.11.1-alpha.4"
114
114
  }
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import isEmpty from 'lodash/isEmpty';
@@ -21,14 +21,14 @@ export const ButtonEmphasis = Emphasis;
21
21
  * Defines the props of the component.
22
22
  */
23
23
  export interface ButtonProps extends BaseButtonProps {
24
- /** Button content. */
25
- children?: ReactNode;
26
24
  /** Left icon (SVG path). */
27
25
  leftIcon?: string;
28
26
  /** Right icon (SVG path). */
29
27
  rightIcon?: string;
30
28
  /** When `true`, the button gets as large as possible. */
31
29
  fullWidth?: boolean;
30
+ /** Children */
31
+ children?: React.ReactNode;
32
32
  }
33
33
 
34
34
  /**
@@ -44,8 +44,6 @@ export interface BaseButtonProps
44
44
  type?: HTMLButtonProps['type'];
45
45
  /** Custom react component for the link (can be used to inject react router Link). */
46
46
  linkAs?: 'a' | any;
47
- /** Children */
48
- children?: React.ReactNode;
49
47
  }
50
48
 
51
49
  export interface ButtonRootProps extends BaseButtonProps {
@@ -16,7 +16,6 @@ import {
16
16
  Elevation,
17
17
  Message,
18
18
  FlexBox,
19
- FlexBoxProps,
20
19
  IconButtonProps,
21
20
  } from '@lumx/react';
22
21
  import range from 'lodash/range';
@@ -165,28 +164,25 @@ export const TestUpdatingChildrenAndMovingAnchor = {
165
164
 
166
165
  const [text, setText] = useState('Initial large span of text');
167
166
  const [anchorSize, setAnchorSize] = useState<IconButtonProps['size']>('m');
168
- const [anchorPosition, setAnchorPosition] = useState<FlexBoxProps['vAlign']>('center');
169
167
  useEffect(() => {
170
168
  if (isOpen) {
171
169
  const timers = [
170
+ // Update popover size
172
171
  setTimeout(() => setText('Text'), 1000),
173
- setTimeout(() => setAnchorSize('s'), 1500),
174
- setTimeout(() => setAnchorPosition('left'), 2000),
172
+ // Update anchor size
173
+ setTimeout(() => setAnchorSize('s'), 1000),
175
174
  ];
176
175
  return () => timers.forEach(clearTimeout);
177
176
  }
178
177
  setText('Initial large span of text');
179
178
  setAnchorSize('m');
180
- setAnchorPosition('center');
181
179
  return undefined;
182
180
  }, [isOpen]);
183
181
 
184
182
  return (
185
183
  <FlexBox orientation="vertical" gap="huge">
186
- <Message kind="info">
187
- Test popover text resize (after 1sec), anchor resize (after 1.5sec) and anchor move (after 2sec)
188
- </Message>
189
- <FlexBox orientation="horizontal" vAlign={anchorPosition}>
184
+ <Message kind="info">Test popover text resize (after 1sec) and anchor resize (after 1.5sec)</Message>
185
+ <FlexBox orientation="horizontal" vAlign="center">
190
186
  <IconButton
191
187
  label="Notifications"
192
188
  className="lumx-spacing-margin-right-huge"
@@ -6,7 +6,7 @@ import classNames from 'classnames';
6
6
  import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
7
7
  import { useFocus } from '@lumx/react/hooks/useFocus';
8
8
  import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
9
- import { DOCUMENT } from '@lumx/react/constants';
9
+ import { DOCUMENT, VISUALLY_HIDDEN } from '@lumx/react/constants';
10
10
  import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
11
11
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
12
12
  import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
@@ -167,6 +167,8 @@ const _InnerPopover = forwardRef<PopoverProps, HTMLDivElement>((props, ref) => {
167
167
  elevation: Math.min(elevation || 0, 5),
168
168
  position,
169
169
  }),
170
+ // Do not show the popover while it's not properly placed
171
+ !styles.popover?.transform ? VISUALLY_HIDDEN : undefined,
170
172
  )}
171
173
  style={styles.popover}
172
174
  {...attributes.popper}
@@ -141,19 +141,10 @@ export function usePopoverStyle({
141
141
  if (!update || !popperElement || !anchorElement || !WINDOW?.ResizeObserver) {
142
142
  return undefined;
143
143
  }
144
-
145
- // Only update once per frame
146
- let frame: number | undefined;
147
- function limitedUpdate() {
148
- if (frame) return;
149
- frame = requestAnimationFrame(() => {
150
- update?.();
151
- frame = undefined;
152
- });
153
- }
144
+ update();
154
145
 
155
146
  // On anchor or popover resize
156
- const resizeObserver = new ResizeObserver(limitedUpdate);
147
+ const resizeObserver = new ResizeObserver(update);
157
148
  resizeObserver.observe(anchorElement);
158
149
  resizeObserver.observe(popperElement);
159
150
  return () => {
@@ -170,9 +161,6 @@ export function usePopoverStyle({
170
161
  newStyles.maxHeight = WINDOW?.innerHeight || DOCUMENT?.documentElement.clientHeight;
171
162
  }
172
163
 
173
- // Do not show the popover while it's not properly placed
174
- if (!newStyles.transform) newStyles.opacity = 0;
175
-
176
164
  return newStyles;
177
165
  }, [style, styles.popper, zIndex, fitWithinViewportHeight]);
178
166