@pushwoosh/dumb-components 1.0.31 → 1.0.32
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/DropdownMenu/components/DropdownMenu/DropdownMenu.js +15 -3
- package/DropdownMenu/components/DropdownMenu/styles.d.ts +1 -0
- package/DropdownMenu/components/DropdownMenu/styles.js +3 -1
- package/DropdownMenu/components/DropdownMenu/types.d.ts +5 -4
- package/FieldBox/FieldBox.js +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { autoPlacement, offset, useFloating } from '@floating-ui/react-dom';
|
|
2
|
-
import React, {
|
|
1
|
+
import { autoPlacement, size, offset, useFloating } from '@floating-ui/react-dom';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
3
4
|
import { Place } from './styles';
|
|
4
5
|
import { DropdownContext } from '../../context';
|
|
5
6
|
const defaultPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end'];
|
|
@@ -9,14 +10,24 @@ export const DropdownMenu = ({
|
|
|
9
10
|
isScrollable,
|
|
10
11
|
menuZIndex,
|
|
11
12
|
menuPlacement,
|
|
13
|
+
fullWidth,
|
|
12
14
|
children
|
|
13
15
|
}) => {
|
|
14
16
|
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
+
const [width, setWidth] = useState(null);
|
|
15
18
|
const {
|
|
16
19
|
refs,
|
|
17
20
|
floatingStyles
|
|
18
21
|
} = useFloating({
|
|
19
|
-
middleware: [
|
|
22
|
+
middleware: [size({
|
|
23
|
+
apply({
|
|
24
|
+
rects
|
|
25
|
+
}) {
|
|
26
|
+
if (fullWidth) {
|
|
27
|
+
flushSync(() => setWidth(rects.reference.width));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}), offset(4), autoPlacement({
|
|
20
31
|
allowedPlacements: menuPlacement ? [menuPlacement] : defaultPlacements
|
|
21
32
|
})]
|
|
22
33
|
});
|
|
@@ -44,6 +55,7 @@ export const DropdownMenu = ({
|
|
|
44
55
|
ref: refs.setFloating,
|
|
45
56
|
style: floatingStyles,
|
|
46
57
|
"$color": color,
|
|
58
|
+
"$width": width,
|
|
47
59
|
"$scrollable": isScrollable,
|
|
48
60
|
"$zIndex": menuZIndex
|
|
49
61
|
}, typeof children === 'function' ? children() : children));
|
|
@@ -5,9 +5,11 @@ const scrollableCss = css(["max-height:248px;overflow-y:auto;"]);
|
|
|
5
5
|
export const Place = styled(Vertical).withConfig({
|
|
6
6
|
displayName: "Place",
|
|
7
7
|
componentId: "sc-ij8wqc-0"
|
|
8
|
-
})(["border:1px solid ", ";background:", ";min-width:140px;", " border-radius:", ";box-shadow:", ";z-index:", ";"], Color.FORM, ({
|
|
8
|
+
})(["border:1px solid ", ";background:", ";width:", ";min-width:140px;max-width:480px;", " border-radius:", ";box-shadow:", ";z-index:", ";"], Color.FORM, ({
|
|
9
9
|
$color
|
|
10
10
|
}) => $color || Color.FROZEN, ({
|
|
11
|
+
$width
|
|
12
|
+
}) => $width ? `${$width}px` : 'auto', ({
|
|
11
13
|
$scrollable
|
|
12
14
|
}) => $scrollable && scrollableCss, ShapeRadius.CONTROL, Shadow.REGULAR, ({
|
|
13
15
|
$zIndex
|
|
@@ -2,15 +2,16 @@ import type { ReferenceType, Placement } from '@floating-ui/react-dom';
|
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import type { Color } from '@pushwoosh/kit-constants';
|
|
4
4
|
export type HandlerProps = {
|
|
5
|
-
onClick: () => void;
|
|
6
|
-
ref: (el: ReferenceType | null) => void;
|
|
7
5
|
isOpen: boolean;
|
|
6
|
+
ref: (el: ReferenceType | null) => void;
|
|
7
|
+
onClick: () => void;
|
|
8
8
|
};
|
|
9
9
|
export type DropdownMenuProps = {
|
|
10
|
-
renderHandler: (args: HandlerProps) => ReactNode;
|
|
11
|
-
children: (() => ReactNode) | ReactNode;
|
|
12
10
|
color?: Color.CLEAR | Color.FROZEN;
|
|
13
11
|
isScrollable?: boolean;
|
|
14
12
|
menuZIndex?: number;
|
|
15
13
|
menuPlacement?: Placement;
|
|
14
|
+
fullWidth?: boolean;
|
|
15
|
+
renderHandler: (args: HandlerProps) => ReactNode;
|
|
16
|
+
children: (() => ReactNode) | ReactNode;
|
|
16
17
|
};
|
package/FieldBox/FieldBox.js
CHANGED
|
@@ -45,10 +45,10 @@ export function FieldBox(props) {
|
|
|
45
45
|
"$alignItems": "center",
|
|
46
46
|
"$gap": Spacing.S1
|
|
47
47
|
}, actions)), children, description && !error && React.createElement(Text, {
|
|
48
|
-
"$variant": "
|
|
48
|
+
"$variant": "footnote",
|
|
49
49
|
"$color": Color.LOCKED
|
|
50
50
|
}, description), error && React.createElement(Text, {
|
|
51
|
-
"$variant": "
|
|
51
|
+
"$variant": "footnote",
|
|
52
52
|
"$color": Color.DANGER
|
|
53
53
|
}, error));
|
|
54
54
|
}
|