@foris/avocado-suite 1.7.0 → 1.8.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/avocado-suite.es.js +10267 -9781
- package/dist/avocado-suite.umd.js +125 -125
- package/dist/components/menu/Menu.d.ts +6 -0
- package/dist/hooks/useFloatingPortal/index.d.ts +2 -0
- package/dist/hooks/useFloatingPortal/positionCalculator.d.ts +19 -0
- package/dist/hooks/useFloatingPortal/useFloatingPortal.d.ts +12 -0
- package/dist/hooks/useFloatingPortal/useFloatingPortal.types.d.ts +62 -0
- package/dist/index.d.ts +8 -0
- package/package.json +1 -1
|
@@ -18,6 +18,12 @@ interface MenuProps {
|
|
|
18
18
|
size?: 'sm' | 'md';
|
|
19
19
|
/** Use the variant prop to change the visual style of the Button */
|
|
20
20
|
variant?: ButtonVariant;
|
|
21
|
+
/**
|
|
22
|
+
* Callback that is called when the visibility of the menu changes.
|
|
23
|
+
* Receives a boolean indicating whether the menu list is now visible or not.
|
|
24
|
+
* Useful for syncing the menu's open state with external state or side effects.
|
|
25
|
+
*/
|
|
26
|
+
onVisibleChange?: (isVisible: boolean) => void;
|
|
21
27
|
}
|
|
22
28
|
declare const Menu: FC<MenuProps>;
|
|
23
29
|
export default Menu;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FloatingPortalPosition, FloatingStrategy } from './useFloatingPortal.types';
|
|
2
|
+
interface CalculatePositionParams {
|
|
3
|
+
referenceRect: DOMRect;
|
|
4
|
+
floatingRect: DOMRect;
|
|
5
|
+
strategy: FloatingStrategy;
|
|
6
|
+
offset: [number, number];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Calculates the position to center the floating element
|
|
10
|
+
* on the reference element, applying optional offsets.
|
|
11
|
+
*
|
|
12
|
+
* - For `fixed` strategy: uses viewport-relative coordinates.
|
|
13
|
+
* - For `absolute` strategy: adds page scroll offsets.
|
|
14
|
+
*
|
|
15
|
+
* @param params - The reference and floating element rects, strategy, and offset
|
|
16
|
+
* @returns The calculated `top` and `left` position
|
|
17
|
+
*/
|
|
18
|
+
export declare function calculatePosition(params: CalculatePositionParams): FloatingPortalPosition;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FloatingPortalOptions, UseFloatingPortalReturn } from './useFloatingPortal.types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that renders content in a React Portal centered on a reference element.
|
|
4
|
+
*
|
|
5
|
+
* Position updates are applied directly to the DOM to avoid React re-renders
|
|
6
|
+
* during scroll/resize, which prevents child component state loss (e.g., scroll
|
|
7
|
+
* position inside a Menu, input focus, etc.).
|
|
8
|
+
*
|
|
9
|
+
* @param options - Configuration for the floating portal
|
|
10
|
+
* @returns Refs, position data, a Portal component, and an update function
|
|
11
|
+
*/
|
|
12
|
+
export declare function useFloatingPortal(options?: FloatingPortalOptions): UseFloatingPortalReturn;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type FloatingStrategy = 'absolute' | 'fixed';
|
|
3
|
+
export interface FloatingPortalOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Custom z-index for the floating element
|
|
6
|
+
* @default 1000
|
|
7
|
+
*/
|
|
8
|
+
zIndex?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Positioning strategy
|
|
11
|
+
* @default 'fixed'
|
|
12
|
+
*/
|
|
13
|
+
strategy?: FloatingStrategy;
|
|
14
|
+
/**
|
|
15
|
+
* Offset from the center of the reference element in pixels [x, y]
|
|
16
|
+
* @default [0, 0]
|
|
17
|
+
*/
|
|
18
|
+
offset?: [number, number];
|
|
19
|
+
/**
|
|
20
|
+
* Whether the floating element is open
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
isOpen?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Custom container element to render the portal
|
|
26
|
+
* @default document.body
|
|
27
|
+
*/
|
|
28
|
+
portalContainer?: HTMLElement;
|
|
29
|
+
/**
|
|
30
|
+
* Callback function when the visibility of the reference element changes (e.g. due to scrolling or resizing)
|
|
31
|
+
* @param isVisible - `true` if the reference element is visible, `false` otherwise
|
|
32
|
+
*/
|
|
33
|
+
onIsTargetVisible?: (isVisible: boolean) => void;
|
|
34
|
+
}
|
|
35
|
+
export interface FloatingPortalPosition {
|
|
36
|
+
top: number;
|
|
37
|
+
left: number;
|
|
38
|
+
}
|
|
39
|
+
export interface UseFloatingPortalReturn {
|
|
40
|
+
/**
|
|
41
|
+
* Ref to attach to the reference/trigger element
|
|
42
|
+
*/
|
|
43
|
+
referenceRef: React.RefObject<HTMLElement>;
|
|
44
|
+
/**
|
|
45
|
+
* Ref to attach to the floating element
|
|
46
|
+
*/
|
|
47
|
+
floatingRef: React.RefObject<HTMLElement>;
|
|
48
|
+
/**
|
|
49
|
+
* Current position styles for the floating element
|
|
50
|
+
*/
|
|
51
|
+
position: FloatingPortalPosition;
|
|
52
|
+
/**
|
|
53
|
+
* Portal component to wrap the floating content
|
|
54
|
+
*/
|
|
55
|
+
Portal: React.FC<{
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Forces a position update
|
|
60
|
+
*/
|
|
61
|
+
update: () => void;
|
|
62
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ import AccessPanel from './components/access-panel/AccessPanel';
|
|
|
56
56
|
import AccountMenu from './components/account-menu/AccountMenu';
|
|
57
57
|
import Header from './components/header/Header';
|
|
58
58
|
import { toast } from 'react-toastify';
|
|
59
|
+
/**
|
|
60
|
+
* Hooks
|
|
61
|
+
*/
|
|
62
|
+
export { useFloatingPortal } from './hooks/useFloatingPortal';
|
|
59
63
|
export { Banner, Header, Drawer, AccessPanel, AccountMenu, SidebarMenu, Weekly, WeeklyGroup, Accordion, Box, Breadcrumbs, Button, Card, CardAccordion, CardNotification, Checkbox, DataCard, DataTable, DatePicker, Divider, Donut, DonutLabels, DonutLegend, DropdownButton, Heading, Link, Loading, Menu, Modal, Pager, Pill, PreviewerMarkdown, Processing, ProgressBar, RadioButton, RoundButton, Select, SelectPagination, SkeletonBase, SkeletonCircle, Stepper, Switch, Tabs, Tag, Text, TextField, Textarea, ThemeProvider, ThemeStore, LocaleStore, Timer, Toaster, Tooltip, Table, toast, };
|
|
60
64
|
/**
|
|
61
65
|
* Types
|
|
@@ -76,3 +80,7 @@ export type { ModalProps } from './components/modal/Modal';
|
|
|
76
80
|
export type { PillProps } from './components/Pill/Pill';
|
|
77
81
|
export type { ThemeMode, Theme } from './types/theme.types';
|
|
78
82
|
export * from './types/table.types';
|
|
83
|
+
/**
|
|
84
|
+
* Hook Types
|
|
85
|
+
*/
|
|
86
|
+
export type { FloatingStrategy, FloatingPortalOptions, FloatingPortalPosition, UseFloatingPortalReturn, } from './hooks/useFloatingPortal';
|