uikit-react-public 0.29.5 → 0.30.0
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/Accordion/Accordion.stories.d.ts +1 -1
- package/dist/components/Alert/Alert.stories.d.ts +1 -1
- package/dist/components/AppHeader/AppHeader.stories.d.ts +1 -1
- package/dist/components/AppMenu/AppMenu.stories.d.ts +1 -1
- package/dist/components/Avatar/Avatar.stories.d.ts +1 -1
- package/dist/components/Badge/Badge.stories.d.ts +1 -1
- package/dist/components/BaseCheckbox/BaseCheckbox.stories.d.ts +1 -1
- package/dist/components/Blanket/Blanket.stories.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +1 -1
- package/dist/components/Button/Button.stories.d.ts +1 -1
- package/dist/components/Calendar/Calendar.stories.d.ts +1 -1
- package/dist/components/Calendar/subcomponents/Day.stories.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.stories.d.ts +1 -1
- package/dist/components/Chip/Chip.stories.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.stories.d.ts +1 -1
- package/dist/components/Dialog/Dialog.stories.d.ts +1 -1
- package/dist/components/Divider/Divider.stories.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.stories.d.ts +1 -1
- package/dist/components/FeedbackDialog/FeedbackDialog.stories.d.ts +1 -1
- package/dist/components/Field/Field.stories.d.ts +1 -1
- package/dist/components/FileInput/FileInput.stories.d.ts +1 -1
- package/dist/components/Footer/Footer.stories.d.ts +1 -1
- package/dist/components/Header/Header.stories.d.ts +1 -1
- package/dist/components/Heading/Heading.stories.d.ts +1 -1
- package/dist/components/Icon/Icon.stories.d.ts +1 -1
- package/dist/components/IconButton/IconButton.stories.d.ts +1 -1
- package/dist/components/Input/Input.stories.d.ts +1 -1
- package/dist/components/Label/Label.stories.d.ts +1 -1
- package/dist/components/Layout/Layout.stories.d.ts +1 -1
- package/dist/components/Link/Link.stories.d.ts +1 -1
- package/dist/components/Main/Main.stories.d.ts +1 -1
- package/dist/components/Modal/Modal.stories.d.ts +1 -1
- package/dist/components/NativeDatepicker/NativeDatepicker.stories.d.ts +1 -1
- package/dist/components/Overlay/Overlay.d.ts +14 -3
- package/dist/components/Overlay/Overlay.stories.d.ts +33 -4
- package/dist/components/Overlay/__tests__/Overlay.test.d.ts +1 -0
- package/dist/components/Overlay/index.d.ts +1 -1
- package/dist/components/Pagination/Pagination.stories.d.ts +1 -1
- package/dist/components/Paragraph/Paragraph.stories.d.ts +1 -1
- package/dist/components/Radio/Radio.stories.d.ts +1 -1
- package/dist/components/Search/Search.stories.d.ts +1 -1
- package/dist/components/Select/Select.stories.d.ts +13 -1
- 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/components/Snackbar/Snackbar.stories.d.ts +1 -1
- package/dist/components/Spinner/Spinner.stories.d.ts +1 -1
- package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +1 -1
- package/dist/components/Table/Table.stories.d.ts +1 -1
- package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +2 -2
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +2 -2
- package/dist/components/Tabs/Tab.d.ts +11 -5
- package/dist/components/Tabs/TabContext.d.ts +14 -8
- package/dist/components/Tabs/Tabs.d.ts +25 -8
- package/dist/components/Tabs/Tabs.stories.d.ts +5 -9
- package/dist/components/Tabs/TabsList.d.ts +9 -0
- package/dist/components/Tabs/TabsPanel.d.ts +10 -0
- package/dist/components/Tabs/index.d.ts +2 -1
- package/dist/components/Textarea/Textarea.stories.d.ts +1 -1
- package/dist/components/Timepicker/Timepicker.stories.d.ts +1 -1
- package/dist/components/Toggle/Toggle.stories.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -1
- package/dist/components/UclLogo/UclLogo.stories.d.ts +1 -1
- package/dist/components/WeekPicker/WeekPicker.stories.d.ts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/index.js +5094 -4723
- package/lib/Welcome.mdx +1 -1
- package/lib/components/Accordion/Accordion.stories.tsx +1 -1
- package/lib/components/Alert/Alert.mdx +1 -1
- package/lib/components/Alert/Alert.stories.tsx +1 -1
- package/lib/components/AppHeader/AppHeader.stories.tsx +1 -1
- package/lib/components/AppMenu/AppMenu.stories.tsx +1 -1
- package/lib/components/Avatar/Avatar.mdx +1 -1
- package/lib/components/Avatar/Avatar.stories.tsx +1 -1
- package/lib/components/Badge/Badge.stories.tsx +1 -1
- package/lib/components/BaseCheckbox/BaseCheckbox.stories.tsx +2 -2
- package/lib/components/Blanket/Blanket.stories.tsx +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
- package/lib/components/Button/Button.mdx +1 -1
- package/lib/components/Button/Button.stories.tsx +2 -2
- package/lib/components/Calendar/Calendar.stories.tsx +2 -2
- package/lib/components/Calendar/subcomponents/Day.stories.tsx +1 -1
- package/lib/components/Checkbox/Checkbox.stories.tsx +2 -2
- package/lib/components/Chip/Chip.stories.tsx +2 -2
- package/lib/components/Datepicker/Datepicker.stories.tsx +2 -2
- package/lib/components/Dialog/Dialog.stories.tsx +1 -1
- package/lib/components/Divider/Divider.stories.tsx +1 -1
- package/lib/components/Dropdown/Dropdown.stories.tsx +1 -1
- package/lib/components/FeedbackDialog/FeedbackDialog.stories.tsx +1 -1
- package/lib/components/Field/Field.stories.tsx +2 -2
- package/lib/components/FileInput/FileInput.stories.tsx +1 -1
- package/lib/components/Footer/Footer.stories.tsx +1 -1
- package/lib/components/Header/Header.mdx +1 -1
- package/lib/components/Header/Header.stories.tsx +1 -1
- package/lib/components/Heading/Documentation.mdx +1 -1
- package/lib/components/Heading/Heading.stories.tsx +1 -1
- package/lib/components/Icon/Icon.stories.tsx +1 -1
- package/lib/components/IconButton/IconButton.stories.tsx +1 -1
- package/lib/components/Input/Documentation.mdx +1 -1
- package/lib/components/Input/Input.stories.tsx +1 -1
- package/lib/components/Label/Label.stories.tsx +1 -1
- package/lib/components/Layout/Layout.stories.tsx +1 -1
- package/lib/components/Link/Link.stories.tsx +1 -1
- package/lib/components/Main/Main.stories.tsx +1 -1
- package/lib/components/Modal/Modal.stories.tsx +1 -1
- package/lib/components/NativeDatepicker/NativeDatepicker.stories.tsx +2 -2
- package/lib/components/Overlay/Overlay.stories.tsx +1 -1
- package/lib/components/Overlay/Overlay.tsx +64 -21
- package/lib/components/Overlay/__tests__/Overlay.test.tsx +81 -0
- package/lib/components/Overlay/index.ts +1 -1
- package/lib/components/Pagination/Pagination.stories.tsx +1 -1
- package/lib/components/Paragraph/Paragraph.stories.tsx +1 -1
- package/lib/components/Radio/Radio.stories.tsx +2 -2
- package/lib/components/Search/Search.stories.tsx +1 -1
- package/lib/components/Select/Select.mdx +1 -1
- package/lib/components/Select/Select.stories.tsx +9 -2
- package/lib/components/Select/Select.tsx +7 -0
- package/lib/components/Select/Select.types.ts +9 -2
- 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/lib/components/Snackbar/Snackbar.stories.tsx +1 -1
- package/lib/components/Spinner/Spinner.stories.tsx +1 -1
- package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +1 -1
- package/lib/components/Table/Table.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +2 -2
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +1 -1
- package/lib/components/Tabs/Tab.tsx +209 -36
- package/lib/components/Tabs/TabContext.tsx +20 -7
- package/lib/components/Tabs/Tabs.stories.tsx +87 -68
- package/lib/components/Tabs/Tabs.tsx +129 -37
- package/lib/components/Tabs/TabsList.tsx +134 -0
- package/lib/components/Tabs/TabsPanel.tsx +55 -0
- package/lib/components/Tabs/__tests__/Tabs.test.tsx +173 -105
- package/lib/components/Tabs/index.ts +8 -1
- package/lib/components/Textarea/Textarea.stories.tsx +1 -1
- package/lib/components/Timepicker/Timepicker.stories.tsx +1 -1
- package/lib/components/Toggle/Documentation.mdx +1 -1
- package/lib/components/Toggle/Toggle.stories.tsx +1 -1
- package/lib/components/Tooltip/Tooltip.stories.tsx +1 -1
- package/lib/components/UclLogo/UclLogo.stories.tsx +1 -1
- package/lib/components/WeekPicker/WeekPicker.stories.tsx +2 -2
- package/lib/components/common/Common.mdx +1 -1
- package/lib/components/index.ts +7 -1
- package/lib/theme/Icons.mdx +1 -1
- package/lib/theme/Typography.mdx +1 -1
- package/package.json +8 -11
- package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +0 -185
package/lib/Welcome.mdx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AvatarStories from "./Avatar.stories";
|
|
2
|
-
import { Meta, Title, Subtitle, Canvas, Controls, ArgTypes } from "@storybook/blocks";
|
|
2
|
+
import { Meta, Title, Subtitle, Canvas, Controls, ArgTypes } from "@storybook/addon-docs/blocks";
|
|
3
3
|
|
|
4
4
|
export const usage = {
|
|
5
5
|
image: `<Avatar
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
import Avatar, { type AvatarProps } from './Avatar';
|
|
4
4
|
import sampleAvatarPhoto from '../../../public/sample-avatar-photo.jpg';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useArgs } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useArgs } from 'storybook/preview-api';
|
|
3
3
|
|
|
4
4
|
import BaseCheckbox from './BaseCheckbox';
|
|
5
5
|
import Icon from '../Icon';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useArgs } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useArgs } from 'storybook/preview-api';
|
|
3
3
|
import Button from './Button';
|
|
4
4
|
import Icon from '../Icon';
|
|
5
5
|
import { theme } from '../../theme';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import Calendar from './Calendar';
|
|
3
|
-
import { useArgs } from '
|
|
3
|
+
import { useArgs } from 'storybook/preview-api';
|
|
4
4
|
import type { AcademicWeek } from './Calendar.types';
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useArgs } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useArgs } from 'storybook/preview-api';
|
|
3
3
|
import Datepicker from './Datepicker';
|
|
4
4
|
import Field from '../Field';
|
|
5
5
|
import Label from '../Label';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { useArgs } from '
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import { useArgs } from 'storybook/preview-api';
|
|
4
4
|
import { css } from '@emotion/css';
|
|
5
5
|
import Field from './Field';
|
|
6
6
|
// Direct imports to avoid circular dependency warning at build time due to context
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as HeaderStories from "./Header.stories";
|
|
2
|
-
import { Meta, Title, Subtitle, Canvas, Controls } from "@storybook/blocks";
|
|
2
|
+
import { Meta, Title, Subtitle, Canvas, Controls } from "@storybook/addon-docs/blocks";
|
|
3
3
|
|
|
4
4
|
export const usage = {
|
|
5
5
|
default: `<Header title='App Name' />`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useArgs } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useArgs } from 'storybook/preview-api';
|
|
3
3
|
import NativeDatepicker from './NativeDatepicker';
|
|
4
4
|
|
|
5
5
|
const meta = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HTMLAttributes,
|
|
3
|
+
CSSProperties,
|
|
3
4
|
forwardRef,
|
|
4
5
|
memo,
|
|
5
6
|
useLayoutEffect,
|
|
@@ -15,8 +16,11 @@ import {
|
|
|
15
16
|
flip as fuiFlip,
|
|
16
17
|
shift as fuiShift,
|
|
17
18
|
offset as fuiOffset,
|
|
19
|
+
size as fuiSize,
|
|
18
20
|
autoUpdate,
|
|
19
21
|
Placement,
|
|
22
|
+
type FlipOptions,
|
|
23
|
+
type ShiftOptions,
|
|
20
24
|
// Strategy,
|
|
21
25
|
} from '@floating-ui/react-dom';
|
|
22
26
|
|
|
@@ -26,19 +30,29 @@ import Blanket from '../Blanket';
|
|
|
26
30
|
|
|
27
31
|
export const NAME = 'ucl-overlay';
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
type OverlaySizeOptions = {
|
|
34
|
+
padding?: number;
|
|
35
|
+
matchReferenceWidth?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type OverlaySize = {
|
|
39
|
+
referenceWidth: number;
|
|
40
|
+
availableWidth: number;
|
|
41
|
+
availableHeight: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export interface OverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
31
45
|
reference: RefObject<HTMLElement | null>;
|
|
32
46
|
placement?: Placement;
|
|
33
47
|
blanket?: boolean;
|
|
34
|
-
flip?: boolean;
|
|
35
|
-
shift?: boolean;
|
|
48
|
+
flip?: boolean | FlipOptions;
|
|
49
|
+
shift?: boolean | ShiftOptions;
|
|
36
50
|
offset?: number;
|
|
51
|
+
size?: boolean | OverlaySizeOptions;
|
|
37
52
|
arrow?: ReactElement;
|
|
38
53
|
arrowClassName?: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
) => void;
|
|
54
|
+
onSizeChange?: (size: OverlaySize) => void;
|
|
55
|
+
onBlanketClick?: (ev: React.MouseEvent<HTMLDivElement>) => void;
|
|
42
56
|
}
|
|
43
57
|
|
|
44
58
|
export type Ref = HTMLDivElement | null;
|
|
@@ -52,27 +66,51 @@ const Overlay = forwardRef<Ref, OverlayProps>(
|
|
|
52
66
|
flip = true,
|
|
53
67
|
shift = true,
|
|
54
68
|
offset = 0,
|
|
69
|
+
size = false,
|
|
55
70
|
arrow,
|
|
56
71
|
className,
|
|
72
|
+
style: inlineStyle,
|
|
57
73
|
arrowClassName,
|
|
74
|
+
onSizeChange,
|
|
58
75
|
onBlanketClick,
|
|
59
76
|
children,
|
|
60
77
|
...props
|
|
61
78
|
}: OverlayProps,
|
|
62
79
|
forwardedRef
|
|
63
80
|
) => {
|
|
64
|
-
const ref = useRef(null);
|
|
81
|
+
const ref = useRef<HTMLDivElement | null>(null);
|
|
65
82
|
const arrowRef = useRef<HTMLElement>(null);
|
|
66
83
|
|
|
67
|
-
useImperativeHandle<Ref, Ref>(
|
|
68
|
-
forwardedRef,
|
|
69
|
-
() => ref.current
|
|
70
|
-
);
|
|
84
|
+
useImperativeHandle<Ref, Ref>(forwardedRef, () => ref.current);
|
|
71
85
|
|
|
72
86
|
const fuiMiddleware = [];
|
|
73
|
-
if (flip) fuiMiddleware.push(fuiFlip());
|
|
74
|
-
if (shift)
|
|
87
|
+
if (flip) fuiMiddleware.push(fuiFlip(typeof flip === 'object' ? flip : {}));
|
|
88
|
+
if (shift)
|
|
89
|
+
fuiMiddleware.push(fuiShift(typeof shift === 'object' ? shift : {}));
|
|
75
90
|
if (offset) fuiMiddleware.push(fuiOffset(offset));
|
|
91
|
+
if (size) {
|
|
92
|
+
const sizeOptions = typeof size === 'object' ? size : {};
|
|
93
|
+
const { padding = 0, matchReferenceWidth = false } = sizeOptions;
|
|
94
|
+
|
|
95
|
+
fuiMiddleware.push(
|
|
96
|
+
fuiSize({
|
|
97
|
+
padding,
|
|
98
|
+
apply({ availableWidth, availableHeight, elements, rects }) {
|
|
99
|
+
const { style } = elements.floating;
|
|
100
|
+
|
|
101
|
+
onSizeChange?.({
|
|
102
|
+
referenceWidth: rects.reference.width,
|
|
103
|
+
availableWidth: Math.max(0, availableWidth),
|
|
104
|
+
availableHeight: Math.max(0, availableHeight),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (matchReferenceWidth) {
|
|
108
|
+
style.minWidth = `${rects.reference.width}px`;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
}
|
|
76
114
|
|
|
77
115
|
const {
|
|
78
116
|
x,
|
|
@@ -88,9 +126,8 @@ const Overlay = forwardRef<Ref, OverlayProps>(
|
|
|
88
126
|
whileElementsMounted: autoUpdate,
|
|
89
127
|
});
|
|
90
128
|
|
|
91
|
-
const overlayPlacement = currentPlacement.split(
|
|
92
|
-
'
|
|
93
|
-
)[0] as 'left' | 'right' | 'top' | 'bottom';
|
|
129
|
+
const overlayPlacement = currentPlacement.split('-')[0] as
|
|
130
|
+
'left' | 'right' | 'top' | 'bottom';
|
|
94
131
|
|
|
95
132
|
useLayoutEffect(() => {
|
|
96
133
|
refs.setReference(reference.current);
|
|
@@ -135,9 +172,7 @@ const Overlay = forwardRef<Ref, OverlayProps>(
|
|
|
135
172
|
let ArrowComp = null;
|
|
136
173
|
|
|
137
174
|
if (arrow) {
|
|
138
|
-
const arrowElement = arrow as ReactElement<
|
|
139
|
-
HTMLAttributes<HTMLElement>
|
|
140
|
-
>;
|
|
175
|
+
const arrowElement = arrow as ReactElement<HTMLAttributes<HTMLElement>>;
|
|
141
176
|
|
|
142
177
|
arrowStyle = cx(
|
|
143
178
|
arrowBaseStyle,
|
|
@@ -177,12 +212,20 @@ const Overlay = forwardRef<Ref, OverlayProps>(
|
|
|
177
212
|
<>
|
|
178
213
|
{blanket && <Blanket onClick={onBlanketClick} />}
|
|
179
214
|
<div
|
|
180
|
-
ref={
|
|
215
|
+
ref={(node) => {
|
|
216
|
+
ref.current = node;
|
|
217
|
+
refs.setFloating(node);
|
|
218
|
+
}}
|
|
181
219
|
className={style}
|
|
182
220
|
style={{
|
|
221
|
+
...(inlineStyle as CSSProperties),
|
|
183
222
|
position: strategy,
|
|
184
223
|
left: x ?? 0,
|
|
185
224
|
top: y ?? 0,
|
|
225
|
+
visibility:
|
|
226
|
+
x === null || y === null
|
|
227
|
+
? 'hidden'
|
|
228
|
+
: (inlineStyle as CSSProperties | undefined)?.visibility,
|
|
186
229
|
}}
|
|
187
230
|
{...props}
|
|
188
231
|
>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { render, waitFor } from '@testing-library/react';
|
|
4
|
+
import Overlay from '../Overlay';
|
|
5
|
+
|
|
6
|
+
describe('Overlay', () => {
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
vi.restoreAllMocks();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('reports viewport sizing when size is enabled', async () => {
|
|
12
|
+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(
|
|
13
|
+
function (this: HTMLElement) {
|
|
14
|
+
if (this.classList.contains('ucl-overlay')) {
|
|
15
|
+
return {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 48,
|
|
18
|
+
top: 48,
|
|
19
|
+
left: 0,
|
|
20
|
+
right: 120,
|
|
21
|
+
bottom: 88,
|
|
22
|
+
width: 120,
|
|
23
|
+
height: 40,
|
|
24
|
+
toJSON: () => {},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0,
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0,
|
|
33
|
+
right: 240,
|
|
34
|
+
bottom: 48,
|
|
35
|
+
width: 240,
|
|
36
|
+
height: 48,
|
|
37
|
+
toJSON: () => {},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
const handleSizeChange = vi.fn();
|
|
42
|
+
|
|
43
|
+
const TestOverlay = () => {
|
|
44
|
+
const reference = useRef<HTMLButtonElement>(null);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<button
|
|
49
|
+
ref={reference}
|
|
50
|
+
type='button'
|
|
51
|
+
>
|
|
52
|
+
Anchor
|
|
53
|
+
</button>
|
|
54
|
+
<Overlay
|
|
55
|
+
reference={reference}
|
|
56
|
+
size={{ matchReferenceWidth: true }}
|
|
57
|
+
onSizeChange={handleSizeChange}
|
|
58
|
+
>
|
|
59
|
+
Content
|
|
60
|
+
</Overlay>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const result = render(<TestOverlay />);
|
|
66
|
+
const overlay = result.container.querySelector('.ucl-overlay');
|
|
67
|
+
|
|
68
|
+
expect(overlay).toBeInTheDocument();
|
|
69
|
+
|
|
70
|
+
await waitFor(() => {
|
|
71
|
+
expect(overlay).toHaveStyle({
|
|
72
|
+
minWidth: '240px',
|
|
73
|
+
});
|
|
74
|
+
expect(handleSizeChange).toHaveBeenCalledWith({
|
|
75
|
+
referenceWidth: 240,
|
|
76
|
+
availableWidth: expect.any(Number),
|
|
77
|
+
availableHeight: expect.any(Number),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './Overlay';
|
|
2
|
-
export type { OverlayProps } from './Overlay';
|
|
2
|
+
export type { OverlayProps, OverlaySize } from './Overlay';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as SelectStories from "./Select.stories";
|
|
2
|
-
import { Meta, Title, Subtitle, Canvas, Controls, ArgTypes } from "@storybook/blocks";
|
|
2
|
+
import { Meta, Title, Subtitle, Canvas, Controls, ArgTypes } from "@storybook/addon-docs/blocks";
|
|
3
3
|
|
|
4
4
|
export const usage = {
|
|
5
5
|
default: `<Select
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useArgs } from '
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useArgs } from 'storybook/preview-api';
|
|
3
3
|
import Select from './Select';
|
|
4
4
|
import { css } from '@emotion/css';
|
|
5
5
|
|
|
@@ -100,6 +100,13 @@ const meta = {
|
|
|
100
100
|
control: { type: 'boolean' },
|
|
101
101
|
table: { type: { summary: 'boolean' } },
|
|
102
102
|
},
|
|
103
|
+
dropdownWidth: {
|
|
104
|
+
description:
|
|
105
|
+
'Control whether the options panel grows to content or matches the Select width',
|
|
106
|
+
control: { type: 'radio' },
|
|
107
|
+
options: ['content', 'match-select'],
|
|
108
|
+
table: { type: { summary: "'content' | 'match-select'" } },
|
|
109
|
+
},
|
|
103
110
|
panelClassName: {
|
|
104
111
|
description: 'Custom className for the options panel',
|
|
105
112
|
control: { type: 'text' },
|