@indico-data/design-system 2.27.0 → 2.28.1
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/lib/index.css +10 -11
- package/lib/index.d.ts +11 -11
- package/lib/index.esm.css +10 -11
- package/lib/index.esm.js +11101 -10242
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +11150 -10276
- package/lib/index.js.map +1 -1
- package/lib/src/components/floatUI/FloatUI.d.ts +2 -0
- package/lib/src/components/floatUI/FloatUI.stories.d.ts +8 -0
- package/lib/src/components/floatUI/index.d.ts +1 -0
- package/lib/src/components/floatUI/types.d.ts +9 -0
- package/lib/src/components/index.d.ts +1 -1
- package/lib/src/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/floatUI/FloatUI.mdx +84 -0
- package/src/components/floatUI/FloatUI.stories.tsx +157 -0
- package/src/components/floatUI/FloatUI.test.tsx +129 -0
- package/src/components/floatUI/FloatUI.tsx +82 -0
- package/src/components/floatUI/index.ts +1 -0
- package/src/components/floatUI/styles/FloatUI.scss +11 -0
- package/src/components/floatUI/styles/_variables.scss +14 -0
- package/src/components/floatUI/types.ts +10 -0
- package/src/components/index.ts +1 -1
- package/src/index.ts +4 -1
- package/src/styles/index.scss +1 -1
- package/lib/src/components/popper/Popper.d.ts +0 -12
- package/lib/src/components/popper/Popper.stories.d.ts +0 -6
- package/lib/src/components/popper/index.d.ts +0 -1
- package/src/components/popper/Popper.mdx +0 -79
- package/src/components/popper/Popper.stories.tsx +0 -160
- package/src/components/popper/Popper.test.tsx +0 -68
- package/src/components/popper/Popper.tsx +0 -57
- package/src/components/popper/index.ts +0 -1
- package/src/components/popper/styles/Popper.scss +0 -11
- package/src/components/popper/styles/_variables.scss +0 -15
- /package/lib/src/components/{popper/Popper.test.d.ts → floatUI/FloatUI.test.d.ts} +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls } from '@storybook/blocks';
|
|
2
|
-
import * as PopperStories from './Popper.stories';
|
|
3
|
-
import { Col, Row } from '@/components';
|
|
4
|
-
|
|
5
|
-
<Meta title="Components/Popper" of={PopperStories} />
|
|
6
|
-
|
|
7
|
-
# Popper
|
|
8
|
-
|
|
9
|
-
The Popper component is used to display content relative to another element. It can be used for tooltips, dropdowns, and other floating elements. The Popper is positioned using the `@floating-ui/react-dom` library.
|
|
10
|
-
|
|
11
|
-
<Canvas
|
|
12
|
-
of={PopperStories.Default}
|
|
13
|
-
source={{
|
|
14
|
-
code: `
|
|
15
|
-
import React, { useState, useRef } from 'react';
|
|
16
|
-
import { Popper } from '@/components/Popper';
|
|
17
|
-
import { Button } from '@/components/Button';
|
|
18
|
-
import { Menu } from '@/components/Menu';
|
|
19
|
-
|
|
20
|
-
const Example = () => {
|
|
21
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
22
|
-
const buttonRef = useRef<HTMLDivElement | null>(null);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<div>
|
|
26
|
-
<div ref={buttonRef}>
|
|
27
|
-
<Button
|
|
28
|
-
onClick={() => setIsOpen((prev) => !prev)}
|
|
29
|
-
iconName="kabob"
|
|
30
|
-
ariaLabel="Toggle Popper"
|
|
31
|
-
/>
|
|
32
|
-
</div>
|
|
33
|
-
<Popper
|
|
34
|
-
referenceElement={buttonRef.current}
|
|
35
|
-
isOpen={isOpen}
|
|
36
|
-
onClose={() => setIsOpen(false)}
|
|
37
|
-
ariaLabel="Example Popper"
|
|
38
|
-
placement="bottom-start"
|
|
39
|
-
offsetValue={5}
|
|
40
|
-
>
|
|
41
|
-
<Menu>
|
|
42
|
-
<Button
|
|
43
|
-
data-testid="refresh-library"
|
|
44
|
-
ariaLabel="Refresh Data"
|
|
45
|
-
iconName="retrain"
|
|
46
|
-
onClick={() => console.log('Refresh Data')}
|
|
47
|
-
>
|
|
48
|
-
Refresh Data
|
|
49
|
-
</Button>
|
|
50
|
-
<Button
|
|
51
|
-
data-testid="configure-fields"
|
|
52
|
-
ariaLabel="Configure Fields"
|
|
53
|
-
iconName="edit"
|
|
54
|
-
onClick={() => console.log('Configure Fields')}
|
|
55
|
-
>
|
|
56
|
-
Configure Fields
|
|
57
|
-
</Button>
|
|
58
|
-
<Button
|
|
59
|
-
data-testid="delete-library"
|
|
60
|
-
ariaLabel="Delete Library"
|
|
61
|
-
iconName="trash"
|
|
62
|
-
onClick={() => console.log('Delete Library')}
|
|
63
|
-
>
|
|
64
|
-
Delete Library
|
|
65
|
-
</Button>
|
|
66
|
-
</Menu>
|
|
67
|
-
</Popper>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default Example;
|
|
73
|
-
`,
|
|
74
|
-
}}
|
|
75
|
-
/>
|
|
76
|
-
|
|
77
|
-
### The following props are available for the Popper component:
|
|
78
|
-
|
|
79
|
-
<Controls of={PopperStories.Default} />
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
3
|
-
import { Popper, PopperProps } from './Popper';
|
|
4
|
-
import { Button } from '../button';
|
|
5
|
-
import { Menu } from '../menu';
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof Popper> = {
|
|
8
|
-
title: 'Components/Popper',
|
|
9
|
-
component: Popper,
|
|
10
|
-
argTypes: {
|
|
11
|
-
children: {
|
|
12
|
-
control: 'object',
|
|
13
|
-
description: 'The content of the popper.',
|
|
14
|
-
table: {
|
|
15
|
-
category: 'Props',
|
|
16
|
-
type: {
|
|
17
|
-
summary: 'React.ReactNode',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
referenceElement: {
|
|
22
|
-
control: 'object',
|
|
23
|
-
description: 'The element to which the popper is attached.',
|
|
24
|
-
table: {
|
|
25
|
-
category: 'Props',
|
|
26
|
-
type: {
|
|
27
|
-
summary: 'HTMLElement | null',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
isOpen: {
|
|
32
|
-
control: 'boolean',
|
|
33
|
-
description: 'Controls the visibility of the popper.',
|
|
34
|
-
table: {
|
|
35
|
-
category: 'Props',
|
|
36
|
-
type: {
|
|
37
|
-
summary: 'boolean',
|
|
38
|
-
},
|
|
39
|
-
defaultValue: { summary: 'false' },
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
onClose: {
|
|
43
|
-
action: 'closed',
|
|
44
|
-
description: 'Callback function when the popper closes.',
|
|
45
|
-
table: { category: 'callbacks' },
|
|
46
|
-
},
|
|
47
|
-
ariaLabel: {
|
|
48
|
-
control: 'text',
|
|
49
|
-
description: 'Sets the aria-label attribute for the popper.',
|
|
50
|
-
table: {
|
|
51
|
-
category: 'Props',
|
|
52
|
-
type: {
|
|
53
|
-
summary: 'string',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
placement: {
|
|
58
|
-
control: 'select',
|
|
59
|
-
options: [
|
|
60
|
-
'top',
|
|
61
|
-
'top-start',
|
|
62
|
-
'top-end',
|
|
63
|
-
'right',
|
|
64
|
-
'right-start',
|
|
65
|
-
'right-end',
|
|
66
|
-
'bottom',
|
|
67
|
-
'bottom-start',
|
|
68
|
-
'bottom-end',
|
|
69
|
-
'left',
|
|
70
|
-
'left-start',
|
|
71
|
-
'left-end',
|
|
72
|
-
],
|
|
73
|
-
description: 'Sets the placement of the popper.',
|
|
74
|
-
table: {
|
|
75
|
-
category: 'Props',
|
|
76
|
-
type: {
|
|
77
|
-
summary: 'string',
|
|
78
|
-
},
|
|
79
|
-
defaultValue: { summary: 'bottom-start' },
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
offsetValue: {
|
|
83
|
-
control: 'number',
|
|
84
|
-
description: 'Sets the offset value for the popper.',
|
|
85
|
-
table: {
|
|
86
|
-
category: 'Props',
|
|
87
|
-
type: {
|
|
88
|
-
summary: 'number',
|
|
89
|
-
},
|
|
90
|
-
defaultValue: { summary: '5' },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
decorators: [
|
|
95
|
-
(Story: React.ComponentType) => (
|
|
96
|
-
<div
|
|
97
|
-
style={{
|
|
98
|
-
height: '160px',
|
|
99
|
-
}}
|
|
100
|
-
>
|
|
101
|
-
<Story />
|
|
102
|
-
</div>
|
|
103
|
-
),
|
|
104
|
-
],
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export default meta;
|
|
108
|
-
|
|
109
|
-
type Story = StoryObj<PopperProps>;
|
|
110
|
-
|
|
111
|
-
export const Default: Story = {
|
|
112
|
-
render: (args) => {
|
|
113
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
114
|
-
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<>
|
|
118
|
-
<Button
|
|
119
|
-
ref={buttonRef}
|
|
120
|
-
onClick={() => setIsOpen((prev) => !prev)}
|
|
121
|
-
iconName="kabob"
|
|
122
|
-
ariaLabel="Toggle Popper"
|
|
123
|
-
/>
|
|
124
|
-
<Popper
|
|
125
|
-
{...args}
|
|
126
|
-
referenceElement={buttonRef.current}
|
|
127
|
-
isOpen={isOpen || args.isOpen}
|
|
128
|
-
onClose={() => setIsOpen(false)}
|
|
129
|
-
>
|
|
130
|
-
<Menu>
|
|
131
|
-
<Button
|
|
132
|
-
data-testid="refresh-library"
|
|
133
|
-
ariaLabel="Refresh Data"
|
|
134
|
-
iconName="retrain"
|
|
135
|
-
onClick={() => console.log('Refresh Data')}
|
|
136
|
-
>
|
|
137
|
-
Refresh Data
|
|
138
|
-
</Button>
|
|
139
|
-
<Button
|
|
140
|
-
data-testid="configure-fields"
|
|
141
|
-
ariaLabel="Configure Fields"
|
|
142
|
-
iconName="edit"
|
|
143
|
-
onClick={() => console.log('Configure Fields')}
|
|
144
|
-
>
|
|
145
|
-
Configure Fields
|
|
146
|
-
</Button>
|
|
147
|
-
<Button
|
|
148
|
-
data-testid="delete-library"
|
|
149
|
-
ariaLabel="Delete Library"
|
|
150
|
-
iconName="trash"
|
|
151
|
-
onClick={() => console.log('Delete Library')}
|
|
152
|
-
>
|
|
153
|
-
Delete Library
|
|
154
|
-
</Button>
|
|
155
|
-
</Menu>
|
|
156
|
-
</Popper>
|
|
157
|
-
</>
|
|
158
|
-
);
|
|
159
|
-
},
|
|
160
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import { Popper } from './Popper';
|
|
4
|
-
import { Menu } from '../menu';
|
|
5
|
-
import { Button } from '../button';
|
|
6
|
-
|
|
7
|
-
describe('Popper Component', () => {
|
|
8
|
-
it('renders without display when isOpen is false', () => {
|
|
9
|
-
render(
|
|
10
|
-
<Popper referenceElement={null} isOpen={false} onClose={jest.fn()} ariaLabel="Example Popper">
|
|
11
|
-
<div>Popper Content</div>
|
|
12
|
-
</Popper>,
|
|
13
|
-
);
|
|
14
|
-
expect(screen.queryByText('Popper Content')).not.toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('displays the popper content when isOpen is true', () => {
|
|
18
|
-
render(
|
|
19
|
-
<Popper referenceElement={null} isOpen={true} onClose={jest.fn()} ariaLabel="Example Popper">
|
|
20
|
-
<div>Popper Content</div>
|
|
21
|
-
</Popper>,
|
|
22
|
-
);
|
|
23
|
-
expect(screen.getByText('Popper Content')).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('calls onClose when clicked outside', () => {
|
|
27
|
-
const mockOnClose = jest.fn();
|
|
28
|
-
|
|
29
|
-
render(
|
|
30
|
-
<div>
|
|
31
|
-
<div data-testid="outside">Outside Element</div>
|
|
32
|
-
<Popper
|
|
33
|
-
referenceElement={null}
|
|
34
|
-
isOpen={true}
|
|
35
|
-
onClose={mockOnClose}
|
|
36
|
-
ariaLabel="Example Popper"
|
|
37
|
-
>
|
|
38
|
-
<div>Popper Content</div>
|
|
39
|
-
</Popper>
|
|
40
|
-
</div>,
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
fireEvent.mouseDown(screen.getByTestId('outside'));
|
|
44
|
-
expect(mockOnClose).toHaveBeenCalledTimes(1);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('renders children inside the popper', () => {
|
|
48
|
-
render(
|
|
49
|
-
<Popper referenceElement={null} isOpen={true} onClose={jest.fn()} ariaLabel="Example Popper">
|
|
50
|
-
<Menu>
|
|
51
|
-
<Button ariaLabel="Refresh Data" iconName="retrain">
|
|
52
|
-
Refresh Data
|
|
53
|
-
</Button>
|
|
54
|
-
<Button ariaLabel="Configure Fields" iconName="edit">
|
|
55
|
-
Configure Fields
|
|
56
|
-
</Button>
|
|
57
|
-
<Button ariaLabel="Delete Library" iconName="trash">
|
|
58
|
-
Delete Library
|
|
59
|
-
</Button>
|
|
60
|
-
</Menu>
|
|
61
|
-
</Popper>,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
expect(screen.getByText('Refresh Data')).toBeInTheDocument();
|
|
65
|
-
expect(screen.getByText('Configure Fields')).toBeInTheDocument();
|
|
66
|
-
expect(screen.getByText('Delete Library')).toBeInTheDocument();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { useFloating, offset, flip, shift, Placement } from '@floating-ui/react-dom';
|
|
3
|
-
import { useClickOutside } from '@/hooks/useClickOutside';
|
|
4
|
-
|
|
5
|
-
export type PopperProps = {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
referenceElement: HTMLElement | null;
|
|
8
|
-
isOpen: boolean;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
ariaLabel: string;
|
|
11
|
-
placement?: Placement;
|
|
12
|
-
offsetValue?: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function Popper({
|
|
16
|
-
children,
|
|
17
|
-
referenceElement,
|
|
18
|
-
isOpen,
|
|
19
|
-
onClose,
|
|
20
|
-
ariaLabel,
|
|
21
|
-
placement = 'bottom-start',
|
|
22
|
-
offsetValue = 5,
|
|
23
|
-
}: PopperProps) {
|
|
24
|
-
const popperContentRef = useRef() as React.MutableRefObject<HTMLDivElement>;
|
|
25
|
-
|
|
26
|
-
const { x, y, strategy, refs } = useFloating({
|
|
27
|
-
placement,
|
|
28
|
-
middleware: [offset(offsetValue), flip(), shift()],
|
|
29
|
-
elements: {
|
|
30
|
-
reference: referenceElement,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
useClickOutside(popperContentRef, onClose);
|
|
35
|
-
|
|
36
|
-
if (!isOpen) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div
|
|
42
|
-
ref={refs.setFloating}
|
|
43
|
-
style={{
|
|
44
|
-
position: strategy,
|
|
45
|
-
top: y ?? '',
|
|
46
|
-
left: x ?? '',
|
|
47
|
-
}}
|
|
48
|
-
role="dialog"
|
|
49
|
-
aria-label={ariaLabel}
|
|
50
|
-
className="popper-container"
|
|
51
|
-
>
|
|
52
|
-
<div ref={popperContentRef} className="popper-content">
|
|
53
|
-
{children}
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Popper } from './Popper';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Common Variables
|
|
2
|
-
:root,
|
|
3
|
-
:root [data-theme='light'],
|
|
4
|
-
:root [data-theme='dark'] {
|
|
5
|
-
--pf-popper-background-color: var(--pf-white-color);
|
|
6
|
-
--pf-popper-border-color: var(--pf-gray-color-900);
|
|
7
|
-
--pf-popper-border-radius: var(--pf-rounded);
|
|
8
|
-
--pf-popper-padding: var(--pf-padding-2);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Dark Theme Specific Variables
|
|
12
|
-
:root [data-theme='dark'] {
|
|
13
|
-
--pf-popper-background-color: var(--pf-primary-color-600);
|
|
14
|
-
--pf-popper-border-color: var(--pf-gray-color);
|
|
15
|
-
}
|
|
File without changes
|