uikit-react-public 0.29.5 → 0.29.6
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/dist/components/Overlay/Overlay.d.ts +14 -3
- package/dist/components/Overlay/Overlay.stories.d.ts +31 -2
- package/dist/components/Overlay/__tests__/Overlay.test.d.ts +1 -0
- package/dist/components/Overlay/index.d.ts +1 -1
- package/dist/components/Select/Select.stories.d.ts +12 -0
- package/dist/components/Select/Select.types.d.ts +7 -0
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +1 -1
- package/dist/components/Select/subcomponents/Panel.d.ts +8 -2
- package/dist/index.js +4780 -4662
- package/lib/components/Overlay/Overlay.tsx +67 -21
- package/lib/components/Overlay/__tests__/Overlay.test.tsx +81 -0
- package/lib/components/Overlay/index.ts +1 -1
- package/lib/components/Select/Select.stories.tsx +7 -0
- package/lib/components/Select/Select.tsx +7 -0
- package/lib/components/Select/Select.types.ts +8 -0
- package/lib/components/Select/__tests__/Select.test.tsx +181 -1
- package/lib/components/Select/subcomponents/CustomSelect.tsx +109 -27
- package/lib/components/Select/subcomponents/Panel.tsx +40 -10
- package/package.json +1 -1
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { css, cx } from '@emotion/css';
|
|
2
2
|
import { useTheme } from '../../../theme';
|
|
3
|
+
import type { SelectDropdownWidth } from '../Select.types';
|
|
3
4
|
|
|
4
5
|
const NAME = 'ucl-uikit-select__panel';
|
|
5
6
|
|
|
6
|
-
type PanelProps = React.ComponentPropsWithoutRef<'div'
|
|
7
|
+
type PanelProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
8
|
+
dropdownWidth?: SelectDropdownWidth;
|
|
9
|
+
referenceWidth?: number;
|
|
10
|
+
availableHeight?: number;
|
|
11
|
+
maxWidth?: number;
|
|
12
|
+
};
|
|
7
13
|
|
|
8
|
-
const Panel = ({
|
|
14
|
+
const Panel = ({
|
|
15
|
+
className,
|
|
16
|
+
dropdownWidth = 'content',
|
|
17
|
+
referenceWidth,
|
|
18
|
+
availableHeight,
|
|
19
|
+
maxWidth,
|
|
20
|
+
...props
|
|
21
|
+
}: PanelProps) => {
|
|
9
22
|
const [theme] = useTheme();
|
|
10
23
|
|
|
11
24
|
const handleClick = (event: React.MouseEvent) => {
|
|
@@ -13,15 +26,22 @@ const Panel = ({ className, ...props }: PanelProps) => {
|
|
|
13
26
|
event.stopPropagation();
|
|
14
27
|
};
|
|
15
28
|
|
|
29
|
+
const referenceWidthValue =
|
|
30
|
+
typeof referenceWidth === 'number' ? `${referenceWidth}px` : '100%';
|
|
31
|
+
const maxWidthValue =
|
|
32
|
+
typeof maxWidth === 'number'
|
|
33
|
+
? `min(${maxWidth}px, calc(100vw - (${theme.margin.m32} * 2)))`
|
|
34
|
+
: `calc(100vw - (${theme.margin.m32} * 2))`;
|
|
35
|
+
const maxHeightValue =
|
|
36
|
+
typeof availableHeight === 'number'
|
|
37
|
+
? `min(400px, ${availableHeight}px)`
|
|
38
|
+
: '400px';
|
|
39
|
+
|
|
16
40
|
const baseStyle = css`
|
|
17
|
-
|
|
18
|
-
top: 46px;
|
|
19
|
-
left: -1px; // -1px to align with the border of the field
|
|
20
|
-
z-index: 10; // Required: panel must be 'above' subsquent DOM elements
|
|
21
|
-
min-width: 100%;
|
|
41
|
+
min-width: ${referenceWidthValue};
|
|
22
42
|
width: fit-content;
|
|
23
|
-
max-width:
|
|
24
|
-
max-height:
|
|
43
|
+
max-width: ${maxWidthValue};
|
|
44
|
+
max-height: ${maxHeightValue};
|
|
25
45
|
overflow-y: auto;
|
|
26
46
|
overflow-x: hidden;
|
|
27
47
|
box-sizing: content-box;
|
|
@@ -30,7 +50,17 @@ const Panel = ({ className, ...props }: PanelProps) => {
|
|
|
30
50
|
background-color: ${theme.colour.fill.inverse};
|
|
31
51
|
`;
|
|
32
52
|
|
|
33
|
-
const
|
|
53
|
+
const matchSelectWidthStyle = css`
|
|
54
|
+
width: ${referenceWidthValue};
|
|
55
|
+
max-width: ${referenceWidthValue};
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const style = cx(
|
|
59
|
+
NAME,
|
|
60
|
+
baseStyle,
|
|
61
|
+
dropdownWidth === 'match-select' && matchSelectWidthStyle,
|
|
62
|
+
className
|
|
63
|
+
);
|
|
34
64
|
|
|
35
65
|
return (
|
|
36
66
|
<div
|