@synerise/ds-popover 1.1.1 → 1.2.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/CHANGELOG.md +9 -5
- package/dist/Popover.const.d.ts +3 -0
- package/dist/Popover.const.js +17 -1
- package/dist/Popover.types.d.ts +24 -3
- package/dist/components/PopoverArrow.d.ts +6 -0
- package/dist/components/PopoverArrow.js +31 -0
- package/dist/components/PopoverContent.js +2 -1
- package/dist/components/PopoverContent.styles.d.ts +1 -0
- package/dist/components/PopoverContent.styles.js +2 -0
- package/dist/components/PopoverTrigger.js +11 -3
- package/dist/components/PopoverTrigger.styles.d.ts +1 -0
- package/dist/components/PopoverTrigger.styles.js +5 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -1
- package/dist/contexts/PopoverContext.d.ts +2 -2
- package/dist/hooks/useListNavigationConfig.d.ts +1 -1
- package/dist/hooks/usePopover.d.ts +2 -59
- package/dist/hooks/usePopover.js +10 -3
- package/dist/hooks/usePopoverContext.d.ts +2 -60
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/utils/getMiddleware.d.ts +4 -2
- package/dist/utils/getMiddleware.js +6 -2
- package/dist/utils/getPlacement.d.ts +3 -0
- package/dist/utils/getPlacement.js +4 -0
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,20 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# [1.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-popover@1.1.2...@synerise/ds-popover@1.2.0) (2025-12-19)
|
|
7
7
|
|
|
8
|
+
### Features
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
- **popconfirm:** migrate to popover ([f14f74e](https://github.com/Synerise/synerise-design/commit/f14f74e1f9879ddd8264dc2614723a298b656d2f))
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
## [1.1.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-popover@1.1.1...@synerise/ds-popover@1.1.2) (2025-12-15)
|
|
12
13
|
|
|
14
|
+
**Note:** Version bump only for package @synerise/ds-popover
|
|
13
15
|
|
|
16
|
+
## [1.1.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-popover@1.1.0...@synerise/ds-popover@1.1.1) (2025-11-13)
|
|
14
17
|
|
|
18
|
+
### Bug Fixes
|
|
15
19
|
|
|
20
|
+
- **date-picker:** dropdown state ([e16e4ce](https://github.com/Synerise/synerise-design/commit/e16e4ce8374c374512d0dc59a2361000ab89c8b9))
|
|
16
21
|
|
|
17
22
|
# 1.1.0 (2025-11-06)
|
|
18
23
|
|
|
19
|
-
|
|
20
24
|
### Features
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
- **dropdown:** dropdownMenu component ([f0ec827](https://github.com/Synerise/synerise-design/commit/f0ec82792cdcb021fa9a454912f6e7a892e53895))
|
package/dist/Popover.const.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { type Placement } from '@floating-ui/react';
|
|
2
|
+
import { type LegacyPlacement } from './Popover.types';
|
|
1
3
|
export declare const HOVER_OPEN_DELAY = 100;
|
|
2
4
|
export declare const HOVER_CLOSE_DELAY = 100;
|
|
5
|
+
export declare const PLACEMENT_MAP: Record<LegacyPlacement, Placement>;
|
package/dist/Popover.const.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
export var HOVER_OPEN_DELAY = 100;
|
|
2
|
-
export var HOVER_CLOSE_DELAY = 100;
|
|
2
|
+
export var HOVER_CLOSE_DELAY = 100;
|
|
3
|
+
export var PLACEMENT_MAP = {
|
|
4
|
+
top: 'top',
|
|
5
|
+
bottom: 'bottom',
|
|
6
|
+
left: 'left',
|
|
7
|
+
right: 'right',
|
|
8
|
+
leftTop: 'left-start',
|
|
9
|
+
leftBottom: 'left-end',
|
|
10
|
+
rightTop: 'right-start',
|
|
11
|
+
rightBottom: 'right-end',
|
|
12
|
+
topRight: 'top-end',
|
|
13
|
+
topLeft: 'top-start',
|
|
14
|
+
topCenter: 'top',
|
|
15
|
+
bottomCenter: 'bottom',
|
|
16
|
+
bottomLeft: 'bottom-start',
|
|
17
|
+
bottomRight: 'bottom-end'
|
|
18
|
+
};
|
package/dist/Popover.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type AutoUpdateOptions, type FlipOptions, type OffsetOptions, type OpenChangeReason, type Placement, type ShiftOptions, type UseDismissProps, type UseListNavigationProps, type UseTransitionStylesProps } from '@floating-ui/react';
|
|
1
|
+
import { type CSSProperties, type Dispatch, type ReactNode, type RefObject, type SetStateAction } from 'react';
|
|
2
|
+
import { type ArrowOptions, type AutoUpdateOptions, type FlipOptions, type OffsetOptions, type OpenChangeReason, type Placement, type ShiftOptions, type UseDismissProps, type UseFloatingReturn, type UseInteractionsReturn, type UseListNavigationProps, type UseTransitionStylesProps } from '@floating-ui/react';
|
|
3
3
|
export type PopoverProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
} & PopoverOptions;
|
|
@@ -26,6 +26,7 @@ export type PopoverOptions = {
|
|
|
26
26
|
offsetConfig?: OffsetConfig;
|
|
27
27
|
flipConfig?: FlipConfig;
|
|
28
28
|
shiftConfig?: ShiftConfig;
|
|
29
|
+
arrowConfig?: Omit<ArrowOptions, 'element'>;
|
|
29
30
|
dismissConfig?: UseDismissProps;
|
|
30
31
|
listNavigationConfig?: UseListNavigationProps;
|
|
31
32
|
trigger?: PopoverTriggerType | PopoverTriggerType[];
|
|
@@ -33,7 +34,7 @@ export type PopoverOptions = {
|
|
|
33
34
|
* defaults to theme.variables['zindex-dropdown'],
|
|
34
35
|
*/
|
|
35
36
|
zIndex?: number;
|
|
36
|
-
onOpenChange?:
|
|
37
|
+
onOpenChange?: OpenChangeFn;
|
|
37
38
|
onDismiss?: (event?: Event, reason?: OpenChangeReason) => void;
|
|
38
39
|
getPopupContainer?: (element: HTMLElement) => HTMLElement;
|
|
39
40
|
transitionDuration?: number;
|
|
@@ -41,4 +42,24 @@ export type PopoverOptions = {
|
|
|
41
42
|
placement: Placement;
|
|
42
43
|
}) => Partial<UseTransitionStylesProps>;
|
|
43
44
|
};
|
|
45
|
+
type OpenChangeFn = (open: boolean, event?: Event, reason?: OpenChangeReason) => void;
|
|
46
|
+
export type UsePopoverReturn = Omit<UseFloatingReturn, 'open'> & UseInteractionsReturn & {
|
|
47
|
+
open: boolean;
|
|
48
|
+
setOpen: OpenChangeFn;
|
|
49
|
+
transitionStyles: CSSProperties | undefined;
|
|
50
|
+
modal: boolean | undefined;
|
|
51
|
+
labelId: string | undefined;
|
|
52
|
+
descriptionId: string | undefined;
|
|
53
|
+
setLabelId: Dispatch<SetStateAction<string | undefined>>;
|
|
54
|
+
setDescriptionId: Dispatch<SetStateAction<string | undefined>>;
|
|
55
|
+
getPopupContainer?: (element: HTMLElement) => HTMLElement;
|
|
56
|
+
testId: string;
|
|
57
|
+
zIndex?: number;
|
|
58
|
+
returnFocus?: boolean;
|
|
59
|
+
componentId?: string;
|
|
60
|
+
arrowRef: RefObject<HTMLElement>;
|
|
61
|
+
};
|
|
62
|
+
export type LegacyDropdownPlacement = Exclude<LegacyPlacement, 'right' | 'left' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom'>;
|
|
63
|
+
export type LegacyPopconfirmPlacement = LegacyPlacement;
|
|
64
|
+
export type LegacyPlacement = 'topLeft' | 'top' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottom' | 'bottomCenter' | 'bottomRight' | 'right' | 'left' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
44
65
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type Placement } from '@floating-ui/react';
|
|
3
|
+
export declare const PopoverArrow: ({ children, getClassNameFromPlacement, }: {
|
|
4
|
+
children?: ReactElement;
|
|
5
|
+
getClassNameFromPlacement?: (placement: Placement) => string;
|
|
6
|
+
}) => ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { cloneElement, isValidElement } from 'react';
|
|
3
|
+
import { useTheme } from '@synerise/ds-core';
|
|
4
|
+
import { usePopoverContext } from '../hooks';
|
|
5
|
+
export var PopoverArrow = function PopoverArrow(_ref) {
|
|
6
|
+
var children = _ref.children,
|
|
7
|
+
getClassNameFromPlacement = _ref.getClassNameFromPlacement;
|
|
8
|
+
var theme = useTheme();
|
|
9
|
+
var _usePopoverContext = usePopoverContext(),
|
|
10
|
+
arrowRef = _usePopoverContext.arrowRef,
|
|
11
|
+
placement = _usePopoverContext.placement,
|
|
12
|
+
zIndex = _usePopoverContext.zIndex,
|
|
13
|
+
middlewareData = _usePopoverContext.middlewareData;
|
|
14
|
+
var placementClassName = (getClassNameFromPlacement == null ? void 0 : getClassNameFromPlacement(placement)) || "ds-popover-arrow-" + placement;
|
|
15
|
+
if (/*#__PURE__*/isValidElement(children)) {
|
|
16
|
+
var _children$props, _middlewareData$arrow, _middlewareData$arrow2;
|
|
17
|
+
return /*#__PURE__*/cloneElement(children, {
|
|
18
|
+
// @ts-expect-error ref unknown
|
|
19
|
+
ref: arrowRef,
|
|
20
|
+
// @ts-expect-error props.className may not exist
|
|
21
|
+
className: classNames(placementClassName, (_children$props = children.props) == null ? void 0 : _children$props.className),
|
|
22
|
+
style: {
|
|
23
|
+
zIndex: zIndex !== undefined ? "" + zIndex : theme.variables['zindex-dropdown'],
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
left: (_middlewareData$arrow = middlewareData.arrow) == null ? void 0 : _middlewareData$arrow.x,
|
|
26
|
+
top: (_middlewareData$arrow2 = middlewareData.arrow) == null ? void 0 : _middlewareData$arrow2.y
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return children;
|
|
31
|
+
};
|
|
@@ -5,6 +5,7 @@ import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
5
5
|
import { FloatingFocusManager, FloatingPortal, useMergeRefs } from '@floating-ui/react';
|
|
6
6
|
import { useTheme } from '@synerise/ds-core';
|
|
7
7
|
import { usePopoverContext } from '../hooks/usePopoverContext';
|
|
8
|
+
import { GlobalStyles } from './PopoverContent.styles';
|
|
8
9
|
export var PopoverContent = /*#__PURE__*/forwardRef(function PopoverContent(_ref, propRef) {
|
|
9
10
|
var style = _ref.style,
|
|
10
11
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -54,7 +55,7 @@ export var PopoverContent = /*#__PURE__*/forwardRef(function PopoverContent(_ref
|
|
|
54
55
|
}
|
|
55
56
|
return /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
56
57
|
root: getPopupContainer ? popupContainerRef : undefined
|
|
57
|
-
}, /*#__PURE__*/React.createElement(FloatingFocusManager, {
|
|
58
|
+
}, /*#__PURE__*/React.createElement(GlobalStyles, null), /*#__PURE__*/React.createElement(FloatingFocusManager, {
|
|
58
59
|
initialFocus: -1,
|
|
59
60
|
context: floatingContext,
|
|
60
61
|
modal: modal,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GlobalStyles: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
|
|
@@ -13,11 +13,13 @@ export var PopoverTrigger = /*#__PURE__*/forwardRef(function (_ref, propRef) {
|
|
|
13
13
|
var context = usePopoverContext();
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
15
|
var childrenRef = children.ref;
|
|
16
|
-
var
|
|
16
|
+
var renderAsChild = asChild && /*#__PURE__*/isValidElement(children);
|
|
17
|
+
var refsArray = [propRef, childrenRef, !renderAsChild && context.refs.setReference];
|
|
18
|
+
var ref = useMergeRefs(refsArray.filter(Boolean));
|
|
17
19
|
// `asChild` allows the user to pass any element as the anchor
|
|
18
20
|
// if the child is a component it needs to forward the ref to a html element
|
|
19
21
|
// so that the Popover can position itself correctly.
|
|
20
|
-
if (
|
|
22
|
+
if (renderAsChild) {
|
|
21
23
|
var referenceProps = context.getReferenceProps(_extends({
|
|
22
24
|
ref: ref,
|
|
23
25
|
'data-popover-trigger': true,
|
|
@@ -25,7 +27,13 @@ export var PopoverTrigger = /*#__PURE__*/forwardRef(function (_ref, propRef) {
|
|
|
25
27
|
}, props, children.props, {
|
|
26
28
|
'data-state': context.open ? 'open' : 'closed'
|
|
27
29
|
}));
|
|
28
|
-
return /*#__PURE__*/
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.TriggerAnchor, {
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
hidden: true,
|
|
33
|
+
ref: function ref(node) {
|
|
34
|
+
context.refs.setReference((node == null ? void 0 : node.nextElementSibling) || null);
|
|
35
|
+
}
|
|
36
|
+
}), /*#__PURE__*/cloneElement(children, _extends({}, referenceProps)));
|
|
29
37
|
}
|
|
30
38
|
return /*#__PURE__*/React.createElement(S.Trigger, _extends({
|
|
31
39
|
ref: ref
|
|
@@ -2,4 +2,8 @@ import styled from 'styled-components';
|
|
|
2
2
|
export var Trigger = styled.span.withConfig({
|
|
3
3
|
displayName: "PopoverTriggerstyles__Trigger",
|
|
4
4
|
componentId: "sc-1irht31-0"
|
|
5
|
-
})(["display:flex;"]);
|
|
5
|
+
})(["display:flex;"]);
|
|
6
|
+
export var TriggerAnchor = styled.span.withConfig({
|
|
7
|
+
displayName: "PopoverTriggerstyles__TriggerAnchor",
|
|
8
|
+
componentId: "sc-1irht31-1"
|
|
9
|
+
})(["display:contents !important;"]);
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
-
import { type
|
|
3
|
-
export type ContextType = (
|
|
2
|
+
import { type UsePopoverReturn } from '../Popover.types';
|
|
3
|
+
export type ContextType = (UsePopoverReturn & {
|
|
4
4
|
setLabelId: Dispatch<SetStateAction<string | undefined>>;
|
|
5
5
|
setDescriptionId: Dispatch<SetStateAction<string | undefined>>;
|
|
6
6
|
}) | null;
|
|
@@ -19,6 +19,6 @@ export declare const useListNavigationConfig: (listNavigationConfig?: UseListNav
|
|
|
19
19
|
cols?: number;
|
|
20
20
|
scrollItemIntoView?: boolean | ScrollIntoViewOptions;
|
|
21
21
|
virtualItemRef?: React.MutableRefObject<HTMLElement | null>;
|
|
22
|
-
itemSizes?: import("@floating-ui/
|
|
22
|
+
itemSizes?: import("@floating-ui/react").Dimensions[];
|
|
23
23
|
dense?: boolean;
|
|
24
24
|
};
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export declare const usePopover: ({ initialOpen, placement, modal, trigger, open: controlledOpen, onOpenChange: setControlledOpen, onDismiss, transitionDuration, getPopupContainer, autoUpdate: autoUpdateWhileMounted, dismissConfig, offsetConfig, flipConfig, shiftConfig, testId, componentId, returnFocus, listNavigationConfig, getTransitionConfig, zIndex, }?: PopoverOptions) => {
|
|
4
|
-
modal: boolean | undefined;
|
|
5
|
-
labelId: string | undefined;
|
|
6
|
-
getPopupContainer: ((element: HTMLElement) => HTMLElement) | undefined;
|
|
7
|
-
descriptionId: string | undefined;
|
|
8
|
-
setLabelId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
9
|
-
setDescriptionId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
10
|
-
testId: string;
|
|
11
|
-
zIndex: number | undefined;
|
|
12
|
-
returnFocus: boolean | undefined;
|
|
13
|
-
componentId: string | undefined;
|
|
14
|
-
placement: import("@floating-ui/utils").Placement;
|
|
15
|
-
strategy: import("@floating-ui/utils").Strategy;
|
|
16
|
-
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
17
|
-
x: number;
|
|
18
|
-
y: number;
|
|
19
|
-
isPositioned: boolean;
|
|
20
|
-
update: () => void;
|
|
21
|
-
floatingStyles: React.CSSProperties;
|
|
22
|
-
refs: {
|
|
23
|
-
reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
|
|
24
|
-
floating: React.MutableRefObject<HTMLElement | null>;
|
|
25
|
-
setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
|
|
26
|
-
setFloating: (node: HTMLElement | null) => void;
|
|
27
|
-
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
28
|
-
elements: {
|
|
29
|
-
reference: import("@floating-ui/react-dom").ReferenceType | null;
|
|
30
|
-
floating: HTMLElement | null;
|
|
31
|
-
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
32
|
-
context: {
|
|
33
|
-
x: number;
|
|
34
|
-
y: number;
|
|
35
|
-
placement: import("@floating-ui/utils").Placement;
|
|
36
|
-
strategy: import("@floating-ui/utils").Strategy;
|
|
37
|
-
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
38
|
-
isPositioned: boolean;
|
|
39
|
-
update: () => void;
|
|
40
|
-
floatingStyles: React.CSSProperties;
|
|
41
|
-
open: boolean;
|
|
42
|
-
onOpenChange: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;
|
|
43
|
-
events: import("@floating-ui/react").FloatingEvents;
|
|
44
|
-
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
45
|
-
nodeId: string | undefined;
|
|
46
|
-
floatingId: string | undefined;
|
|
47
|
-
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
48
|
-
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
49
|
-
};
|
|
50
|
-
getReferenceProps: (userProps?: React.HTMLProps<Element>) => Record<string, unknown>;
|
|
51
|
-
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
52
|
-
getItemProps: (userProps?: Omit<React.HTMLProps<HTMLElement>, "selected" | "active"> & {
|
|
53
|
-
active?: boolean;
|
|
54
|
-
selected?: boolean;
|
|
55
|
-
}) => Record<string, unknown>;
|
|
56
|
-
open: boolean;
|
|
57
|
-
setOpen: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;
|
|
58
|
-
transitionStyles: import("react").CSSProperties | undefined;
|
|
59
|
-
};
|
|
1
|
+
import { type PopoverOptions, type UsePopoverReturn } from '../Popover.types';
|
|
2
|
+
export declare const usePopover: ({ initialOpen, placement, modal, trigger, open: controlledOpen, onOpenChange: setControlledOpen, onDismiss, transitionDuration, getPopupContainer, autoUpdate: autoUpdateWhileMounted, dismissConfig, offsetConfig, flipConfig, shiftConfig, arrowConfig, testId, componentId, returnFocus, listNavigationConfig, getTransitionConfig, zIndex, }?: PopoverOptions) => UsePopoverReturn;
|
package/dist/hooks/usePopover.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { autoUpdate, useClick, useDismiss, useFloating, useHover, useInteractions, useListNavigation, useRole, useTransitionStyles } from '@floating-ui/react';
|
|
4
4
|
import { HOVER_CLOSE_DELAY, HOVER_OPEN_DELAY } from '../Popover.const';
|
|
5
5
|
import { getDefaultTransitionConfig, getMiddleware } from '../utils';
|
|
@@ -27,6 +27,8 @@ export var usePopover = function usePopover(_temp) {
|
|
|
27
27
|
flipConfig = _ref$flipConfig === void 0 ? {} : _ref$flipConfig,
|
|
28
28
|
_ref$shiftConfig = _ref.shiftConfig,
|
|
29
29
|
shiftConfig = _ref$shiftConfig === void 0 ? {} : _ref$shiftConfig,
|
|
30
|
+
_ref$arrowConfig = _ref.arrowConfig,
|
|
31
|
+
arrowConfig = _ref$arrowConfig === void 0 ? {} : _ref$arrowConfig,
|
|
30
32
|
_ref$testId = _ref.testId,
|
|
31
33
|
testId = _ref$testId === void 0 ? 'noTestId' : _ref$testId,
|
|
32
34
|
componentId = _ref.componentId,
|
|
@@ -46,6 +48,7 @@ export var usePopover = function usePopover(_temp) {
|
|
|
46
48
|
setDescriptionId = _useState3[1];
|
|
47
49
|
var open = controlledOpen != null ? controlledOpen : uncontrolledOpen;
|
|
48
50
|
var setOpen = setControlledOpen != null ? setControlledOpen : setUncontrolledOpen;
|
|
51
|
+
var arrowRef = useRef(null);
|
|
49
52
|
var triggerArray = Array.isArray(trigger) ? trigger : [trigger];
|
|
50
53
|
var whileElementsMounted = useMemo(function () {
|
|
51
54
|
if (!autoUpdateWhileMounted) {
|
|
@@ -72,7 +75,10 @@ export var usePopover = function usePopover(_temp) {
|
|
|
72
75
|
middleware: getMiddleware({
|
|
73
76
|
offsetConfig: offsetConfig,
|
|
74
77
|
flipConfig: flipConfig,
|
|
75
|
-
shiftConfig: shiftConfig
|
|
78
|
+
shiftConfig: shiftConfig,
|
|
79
|
+
arrowConfig: _extends({}, arrowConfig, {
|
|
80
|
+
element: arrowRef.current
|
|
81
|
+
})
|
|
76
82
|
})
|
|
77
83
|
});
|
|
78
84
|
var context = data.context;
|
|
@@ -113,7 +119,8 @@ export var usePopover = function usePopover(_temp) {
|
|
|
113
119
|
testId: testId,
|
|
114
120
|
zIndex: zIndex,
|
|
115
121
|
returnFocus: returnFocus,
|
|
116
|
-
componentId: componentId
|
|
122
|
+
componentId: componentId,
|
|
123
|
+
arrowRef: arrowRef
|
|
117
124
|
});
|
|
118
125
|
}, [getPopupContainer, isMounted, setOpen, transitionDuration, styles, interactions, data, modal, labelId, descriptionId, zIndex, testId, returnFocus, componentId]);
|
|
119
126
|
};
|
|
@@ -1,60 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
labelId: string | undefined;
|
|
4
|
-
getPopupContainer: ((element: HTMLElement) => HTMLElement) | undefined;
|
|
5
|
-
descriptionId: string | undefined;
|
|
6
|
-
setLabelId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
7
|
-
setDescriptionId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
8
|
-
testId: string;
|
|
9
|
-
zIndex: number | undefined;
|
|
10
|
-
returnFocus: boolean | undefined;
|
|
11
|
-
componentId: string | undefined;
|
|
12
|
-
placement: import("@floating-ui/utils").Placement;
|
|
13
|
-
strategy: import("@floating-ui/utils").Strategy;
|
|
14
|
-
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
isPositioned: boolean;
|
|
18
|
-
update: () => void;
|
|
19
|
-
floatingStyles: React.CSSProperties;
|
|
20
|
-
refs: {
|
|
21
|
-
reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
|
|
22
|
-
floating: React.MutableRefObject<HTMLElement | null>;
|
|
23
|
-
setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
|
|
24
|
-
setFloating: (node: HTMLElement | null) => void;
|
|
25
|
-
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
26
|
-
elements: {
|
|
27
|
-
reference: import("@floating-ui/react-dom").ReferenceType | null;
|
|
28
|
-
floating: HTMLElement | null;
|
|
29
|
-
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
30
|
-
context: {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
placement: import("@floating-ui/utils").Placement;
|
|
34
|
-
strategy: import("@floating-ui/utils").Strategy;
|
|
35
|
-
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
36
|
-
isPositioned: boolean;
|
|
37
|
-
update: () => void;
|
|
38
|
-
floatingStyles: React.CSSProperties;
|
|
39
|
-
open: boolean;
|
|
40
|
-
onOpenChange: (open: boolean, event?: Event, reason?: import("@floating-ui/react").OpenChangeReason) => void;
|
|
41
|
-
events: import("@floating-ui/react").FloatingEvents;
|
|
42
|
-
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
43
|
-
nodeId: string | undefined;
|
|
44
|
-
floatingId: string | undefined;
|
|
45
|
-
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
46
|
-
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
47
|
-
};
|
|
48
|
-
getReferenceProps: (userProps?: React.HTMLProps<Element>) => Record<string, unknown>;
|
|
49
|
-
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
50
|
-
getItemProps: (userProps?: Omit<React.HTMLProps<HTMLElement>, "selected" | "active"> & {
|
|
51
|
-
active?: boolean;
|
|
52
|
-
selected?: boolean;
|
|
53
|
-
}) => Record<string, unknown>;
|
|
54
|
-
open: boolean;
|
|
55
|
-
setOpen: (open: boolean, event?: Event, reason?: import("@floating-ui/react").OpenChangeReason) => void;
|
|
56
|
-
transitionStyles: import("react").CSSProperties | undefined;
|
|
57
|
-
} & {
|
|
58
|
-
setLabelId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
59
|
-
setDescriptionId: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
60
|
-
};
|
|
1
|
+
import { type ContextType } from '../contexts';
|
|
2
|
+
export declare const usePopoverContext: () => Exclude<ContextType, null>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './Popover';
|
|
2
2
|
export * from './components';
|
|
3
3
|
export { Popover as default } from './Popover';
|
|
4
|
-
export * from './Popover.types';
|
|
4
|
+
export * from './Popover.types';
|
|
5
|
+
export { getPlacement } from './utils/getPlacement';
|
|
6
|
+
export { PLACEMENT_MAP } from './Popover.const';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { type ArrowOptions } from '@floating-ui/react';
|
|
1
2
|
import { type FlipConfig, type OffsetConfig, type ShiftConfig } from '../Popover.types';
|
|
2
3
|
type GetMiddleware = {
|
|
3
4
|
offsetConfig: OffsetConfig;
|
|
4
5
|
flipConfig: FlipConfig;
|
|
5
6
|
shiftConfig: ShiftConfig;
|
|
7
|
+
arrowConfig?: ArrowOptions;
|
|
6
8
|
};
|
|
7
|
-
export declare const getMiddleware: ({ offsetConfig, flipConfig, shiftConfig, }: GetMiddleware) => {
|
|
9
|
+
export declare const getMiddleware: ({ offsetConfig, flipConfig, shiftConfig, arrowConfig, }: GetMiddleware) => {
|
|
8
10
|
name: string;
|
|
9
11
|
options?: any;
|
|
10
|
-
fn: (state: import("@floating-ui/
|
|
12
|
+
fn: (state: import("@floating-ui/react").MiddlewareState) => import("@floating-ui/react").MiddlewareReturn | Promise<import("@floating-ui/react").MiddlewareReturn>;
|
|
11
13
|
}[];
|
|
12
14
|
export {};
|
|
@@ -2,11 +2,12 @@ var _excluded = ["enabled"],
|
|
|
2
2
|
_excluded2 = ["enabled"],
|
|
3
3
|
_excluded3 = ["enabled"];
|
|
4
4
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
5
|
-
import { flip, offset, shift } from '@floating-ui/react';
|
|
5
|
+
import { arrow, flip, offset, shift } from '@floating-ui/react';
|
|
6
6
|
export var getMiddleware = function getMiddleware(_ref) {
|
|
7
7
|
var offsetConfig = _ref.offsetConfig,
|
|
8
8
|
flipConfig = _ref.flipConfig,
|
|
9
|
-
shiftConfig = _ref.shiftConfig
|
|
9
|
+
shiftConfig = _ref.shiftConfig,
|
|
10
|
+
arrowConfig = _ref.arrowConfig;
|
|
10
11
|
var middleware = [];
|
|
11
12
|
var _ref2 = offsetConfig || {},
|
|
12
13
|
_ref2$enabled = _ref2.enabled,
|
|
@@ -29,5 +30,8 @@ export var getMiddleware = function getMiddleware(_ref) {
|
|
|
29
30
|
if (shiftEnabled) {
|
|
30
31
|
middleware.push(shift(shiftOptions));
|
|
31
32
|
}
|
|
33
|
+
if (arrowConfig != null && arrowConfig.element) {
|
|
34
|
+
middleware.push(arrow(arrowConfig));
|
|
35
|
+
}
|
|
32
36
|
return middleware;
|
|
33
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-popover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Popover UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,14 +34,16 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@floating-ui/react": "^0.27.
|
|
37
|
+
"@floating-ui/react": "^0.27.16",
|
|
38
|
+
"classnames": "^2.5.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@testing-library/user-event": "^14"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@synerise/ds-core": "*",
|
|
44
|
-
"react": ">=16.9.0 <= 18.3.1"
|
|
45
|
+
"react": ">=16.9.0 <= 18.3.1",
|
|
46
|
+
"styled-components": "^5.3.3"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c638fc7e1af8aea55d466a643329fe499b2b3383"
|
|
47
49
|
}
|