@synerise/ds-dropdown 1.3.0 → 1.3.2
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 +8 -0
- package/README.md +17 -10
- package/dist/Dropdown.const.d.ts +4 -4
- package/dist/Dropdown.const.js +31 -21
- package/dist/Dropdown.d.ts +3 -3
- package/dist/Dropdown.js +64 -81
- package/dist/Dropdown.styles.d.ts +1 -1
- package/dist/Dropdown.styles.js +7 -6
- package/dist/Dropdown.types.d.ts +4 -4
- package/dist/Dropdown.types.js +1 -1
- package/dist/components/BackAction/BackAction.d.ts +2 -2
- package/dist/components/BackAction/BackAction.js +20 -25
- package/dist/components/BackAction/BackAction.styles.d.ts +4 -4
- package/dist/components/BackAction/BackAction.styles.js +15 -17
- package/dist/components/BackAction/BackAction.types.d.ts +2 -2
- package/dist/components/BackAction/BackAction.types.js +1 -1
- package/dist/components/BottomAction/BottomAction.d.ts +2 -2
- package/dist/components/BottomAction/BottomAction.js +15 -17
- package/dist/components/BottomAction/BottomAction.styles.d.ts +3 -3
- package/dist/components/BottomAction/BottomAction.styles.js +11 -18
- package/dist/components/BottomAction/BottomAction.types.d.ts +2 -2
- package/dist/components/BottomAction/BottomAction.types.js +1 -1
- package/dist/components/DropdownFooter/DropdownFooter.d.ts +2 -2
- package/dist/components/DropdownFooter/DropdownFooter.js +15 -10
- package/dist/components/DropdownFooter/DropdownFooter.styles.d.ts +3 -3
- package/dist/components/DropdownFooter/DropdownFooter.styles.js +11 -10
- package/dist/components/DropdownFooter/DropdownFooter.types.d.ts +1 -1
- package/dist/components/DropdownFooter/DropdownFooter.types.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.js +71 -118
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.types.js +1 -1
- package/dist/components/DropdownMenuList/DropdownMenuList.d.ts +3 -3
- package/dist/components/DropdownMenuList/DropdownMenuList.js +62 -76
- package/dist/components/DropdownMenuList/DropdownMenuList.styles.d.ts +5 -5
- package/dist/components/DropdownMenuList/DropdownMenuList.styles.js +16 -9
- package/dist/components/DropdownMenuList/DropdownMenuList.types.d.ts +2 -2
- package/dist/components/DropdownMenuList/DropdownMenuList.types.js +1 -1
- package/dist/components/DropdownOverlay/DropdownOverlay.d.ts +2 -2
- package/dist/components/DropdownOverlay/DropdownOverlay.js +45 -53
- package/dist/components/DropdownOverlay/DropdownOverlay.styles.d.ts +1 -1
- package/dist/components/DropdownOverlay/DropdownOverlay.styles.js +7 -10
- package/dist/components/DropdownOverlay/DropdownOverlay.types.d.ts +2 -2
- package/dist/components/DropdownOverlay/DropdownOverlay.types.js +1 -1
- package/dist/components/DropdownPopover/DropdownPopover.d.ts +2 -2
- package/dist/components/DropdownPopover/DropdownPopover.js +44 -74
- package/dist/components/DropdownPopover/DropdownPopover.types.d.ts +1 -1
- package/dist/components/DropdownPopover/DropdownPopover.types.js +1 -1
- package/dist/components/TextTrigger/TextTrigger.d.ts +2 -2
- package/dist/components/TextTrigger/TextTrigger.js +24 -31
- package/dist/components/TextTrigger/TextTrigger.styles.d.ts +3 -3
- package/dist/components/TextTrigger/TextTrigger.styles.js +9 -23
- package/dist/components/TextTrigger/TextTrigger.types.d.ts +1 -1
- package/dist/components/TextTrigger/TextTrigger.types.js +1 -1
- package/dist/hooks/useDefaultTexts.d.ts +1 -1
- package/dist/hooks/useDefaultTexts.js +18 -20
- package/dist/hooks/useDropdownVisibility.js +19 -21
- package/dist/index.js +15 -6
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/getDropdownWidth.d.ts +1 -1
- package/dist/utils/getDropdownWidth.js +12 -9
- package/dist/utils/getTransitionConfig.d.ts +1 -1
- package/dist/utils/getTransitionConfig.js +11 -7
- package/dist/utils/index.js +8 -3
- package/dist/utils/isSplitFooter.d.ts +1 -1
- package/dist/utils/isSplitFooter.js +6 -3
- package/package.json +16 -16
|
@@ -1,73 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
import classnames from
|
|
3
|
-
import
|
|
4
|
-
import { useMergeRefs } from
|
|
5
|
-
import { getDropdownWidth } from
|
|
6
|
-
import { OverlayWrapper } from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
useEffect(function () {
|
|
23
|
-
if (triggerRef.current && (size === 'match-trigger' || size === 'min-match-trigger')) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { forwardRef, useRef, useState, useEffect } from "react";
|
|
4
|
+
import { useMergeRefs } from "@floating-ui/react";
|
|
5
|
+
import { getDropdownWidth } from "../../utils/getDropdownWidth.js";
|
|
6
|
+
import { OverlayWrapper } from "./DropdownOverlay.styles.js";
|
|
7
|
+
const DropdownOverlay = forwardRef(({
|
|
8
|
+
content,
|
|
9
|
+
size,
|
|
10
|
+
overlayStyle,
|
|
11
|
+
overlayClassName,
|
|
12
|
+
htmlAttributes,
|
|
13
|
+
hideOnItemClick,
|
|
14
|
+
handleItemClick,
|
|
15
|
+
triggerRef
|
|
16
|
+
}, ref) => {
|
|
17
|
+
const overlayWrapperRef = useRef(null);
|
|
18
|
+
const mergedRef = useMergeRefs([overlayWrapperRef, ref]);
|
|
19
|
+
const [overlaySize, setOverlaySize] = useState(getDropdownWidth(size) ?? 0);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (triggerRef.current && (size === "match-trigger" || size === "min-match-trigger")) {
|
|
24
22
|
setOverlaySize(triggerRef.current.clientWidth);
|
|
25
23
|
} else {
|
|
26
|
-
|
|
27
|
-
setOverlaySize((_getDropdownWidth2 = getDropdownWidth(size)) != null ? _getDropdownWidth2 : 0);
|
|
24
|
+
setOverlaySize(getDropdownWidth(size) ?? 0);
|
|
28
25
|
}
|
|
29
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
26
|
}, [size]);
|
|
31
|
-
useEffect(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
handleItemClick == null || handleItemClick();
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const handleItemSelect = (element) => {
|
|
29
|
+
const itemSelector = typeof hideOnItemClick === "string" ? hideOnItemClick : '[role="menuitem"]';
|
|
30
|
+
const listItem = element.closest(itemSelector);
|
|
31
|
+
if (overlayWrapperRef.current?.contains(listItem)) {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
handleItemClick?.();
|
|
39
34
|
}, 0);
|
|
40
35
|
}
|
|
41
36
|
};
|
|
42
|
-
|
|
43
|
-
if (overlayWrapperRef.current && typeof hideOnItemClick ===
|
|
37
|
+
const handleOverlayClick = (event) => {
|
|
38
|
+
if (overlayWrapperRef.current && typeof hideOnItemClick === "string" && event.target instanceof HTMLElement) {
|
|
44
39
|
handleItemSelect(event.target);
|
|
45
40
|
}
|
|
46
41
|
};
|
|
47
|
-
|
|
48
|
-
if (event.key ===
|
|
49
|
-
if (overlayWrapperRef.current && typeof hideOnItemClick ===
|
|
42
|
+
const handleItemEnterPress = (event) => {
|
|
43
|
+
if (event.key === "Enter") {
|
|
44
|
+
if (overlayWrapperRef.current && typeof hideOnItemClick === "string" && event.target instanceof HTMLElement) {
|
|
50
45
|
handleItemSelect(event.target);
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
48
|
};
|
|
54
|
-
|
|
49
|
+
const overlayNode = overlayWrapperRef.current;
|
|
55
50
|
if (overlayNode) {
|
|
56
|
-
overlayNode.addEventListener(
|
|
57
|
-
overlayNode.addEventListener(
|
|
51
|
+
overlayNode.addEventListener("click", handleOverlayClick);
|
|
52
|
+
overlayNode.addEventListener("keydown", handleItemEnterPress);
|
|
58
53
|
}
|
|
59
|
-
return
|
|
54
|
+
return () => {
|
|
60
55
|
if (overlayNode) {
|
|
61
|
-
overlayNode.removeEventListener(
|
|
62
|
-
overlayNode.removeEventListener(
|
|
56
|
+
overlayNode.removeEventListener("click", handleOverlayClick);
|
|
57
|
+
overlayNode.removeEventListener("keydown", handleItemEnterPress);
|
|
63
58
|
}
|
|
64
59
|
};
|
|
65
60
|
});
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
ref: mergedRef
|
|
72
|
-
}, htmlAttributes), content);
|
|
73
|
-
});
|
|
61
|
+
return /* @__PURE__ */ jsx(OverlayWrapper, { style: overlayStyle, className: classnames(overlayClassName, htmlAttributes?.className), $width: overlaySize, widthProperty: size === "min-match-trigger" ? "min-width" : "width", ref: mergedRef, ...htmlAttributes, children: content });
|
|
62
|
+
});
|
|
63
|
+
export {
|
|
64
|
+
DropdownOverlay
|
|
65
|
+
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import { Wrapper
|
|
3
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { Wrapper } from "@synerise/ds-list-item/dist/components/Text/Text.styles";
|
|
3
|
+
const OverlayWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
4
4
|
displayName: "DropdownOverlaystyles__OverlayWrapper",
|
|
5
5
|
componentId: "sc-hy0f4i-0"
|
|
6
|
-
})(["background:", ";box-shadow:", ";border-radius:3px;", ";overflow:hidden;", "{min-width:0;}"],
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, function (props) {
|
|
11
|
-
return props.$width && props.widthProperty + ": " + props.$width + "px";
|
|
12
|
-
}, ListItemWrapper);
|
|
6
|
+
})(["background:", ";box-shadow:", ";border-radius:3px;", ";overflow:hidden;", "{min-width:0;}"], (props) => props.theme.palette.white, (props) => props.theme.variables["box-shadow-2"], (props) => props.$width && `${props.widthProperty}: ${props.$width}px`, Wrapper);
|
|
7
|
+
export {
|
|
8
|
+
OverlayWrapper
|
|
9
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HTMLAttributes, ReactNode, RefObject } from 'react';
|
|
2
|
+
import { DropdownProps } from '../../Dropdown.types';
|
|
3
3
|
export type DropdownOverlayProps = Pick<DropdownProps, 'size' | 'overlayStyle' | 'hideOnItemClick' | 'overlayClassName'> & {
|
|
4
4
|
content: ReactNode;
|
|
5
5
|
triggerRef: RefObject<HTMLElement>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DropdownPopoverProps } from './DropdownPopover.types';
|
|
3
3
|
export declare const DropdownPopover: ({ placement, children, popoverProps, popoverTriggerProps, getPopupContainer, trigger, open, onDismiss, overlay, handleOpenChange, size, handleItemClick, handleTriggerClick, hideOnItemClick, asChild, overlayStyle, overlayClassName, overlayHTMLAttributes, activeIndex, setActiveIndex, }: DropdownPopoverProps) => React.JSX.Element;
|
|
@@ -1,79 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { FloatingList } from
|
|
4
|
-
import { DropdownContextProvider } from
|
|
5
|
-
import {
|
|
6
|
-
import { POPOVER_FLIP_CONFIG, POPOVER_OFFSET_CONFIG,
|
|
7
|
-
import { getTransitionConfig } from
|
|
8
|
-
import { DropdownOverlay } from
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { FloatingList } from "@floating-ui/react";
|
|
4
|
+
import { DropdownContextProvider } from "@synerise/ds-core";
|
|
5
|
+
import { getPlacement, Popover, PopoverTrigger, PopoverContent } from "@synerise/ds-popover";
|
|
6
|
+
import { POPOVER_SHIFT_CONFIG, POPOVER_FLIP_CONFIG, POPOVER_OFFSET_CONFIG, POPOVER_TRANSITION_DURATION } from "../../Dropdown.const.js";
|
|
7
|
+
import { getTransitionConfig } from "../../utils/getTransitionConfig.js";
|
|
8
|
+
import { DropdownOverlay } from "../DropdownOverlay/DropdownOverlay.js";
|
|
9
|
+
const DropdownPopover = ({
|
|
10
|
+
placement = "bottomLeft",
|
|
11
|
+
children,
|
|
12
|
+
popoverProps,
|
|
13
|
+
popoverTriggerProps,
|
|
14
|
+
getPopupContainer,
|
|
15
|
+
trigger,
|
|
16
|
+
open,
|
|
17
|
+
onDismiss,
|
|
18
|
+
overlay,
|
|
19
|
+
handleOpenChange,
|
|
20
|
+
size,
|
|
21
|
+
handleItemClick,
|
|
22
|
+
handleTriggerClick,
|
|
23
|
+
hideOnItemClick,
|
|
24
|
+
asChild,
|
|
25
|
+
overlayStyle,
|
|
26
|
+
overlayClassName,
|
|
27
|
+
overlayHTMLAttributes,
|
|
28
|
+
activeIndex,
|
|
29
|
+
setActiveIndex
|
|
30
|
+
}) => {
|
|
31
|
+
const floatingPlacement = getPlacement(placement);
|
|
32
|
+
const triggerRef = useRef(null);
|
|
33
|
+
const elementsRef = useRef([]);
|
|
34
|
+
const listNavigationConfig = {
|
|
35
35
|
enabled: true,
|
|
36
|
-
activeIndex
|
|
37
|
-
onNavigate:
|
|
36
|
+
activeIndex,
|
|
37
|
+
onNavigate: (newIndex) => {
|
|
38
38
|
setActiveIndex(newIndex);
|
|
39
39
|
},
|
|
40
40
|
listRef: elementsRef
|
|
41
41
|
};
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
autoUpdate: true,
|
|
51
|
-
offsetConfig: POPOVER_OFFSET_CONFIG,
|
|
52
|
-
flipConfig: POPOVER_FLIP_CONFIG,
|
|
53
|
-
shiftConfig: POPOVER_SHIFT_CONFIG,
|
|
54
|
-
getTransitionConfig: getTransitionConfig,
|
|
55
|
-
getPopupContainer: getPopupContainer,
|
|
56
|
-
listNavigationConfig: listNavigationConfig,
|
|
57
|
-
testId: "dropdown"
|
|
58
|
-
}, popoverProps), /*#__PURE__*/React.createElement(PopoverTrigger, _extends({
|
|
59
|
-
ref: triggerRef,
|
|
60
|
-
asChild: asChild,
|
|
61
|
-
onClick: handleTriggerClick
|
|
62
|
-
}, popoverTriggerProps), children), /*#__PURE__*/React.createElement(PopoverContent, null, /*#__PURE__*/React.createElement(DropdownContextProvider, {
|
|
63
|
-
hideOnItemClick: hideOnItemClick,
|
|
64
|
-
activeIndex: activeIndex,
|
|
65
|
-
setIsOpen: handleOpenChange,
|
|
66
|
-
isOpen: !!open
|
|
67
|
-
}, /*#__PURE__*/React.createElement(FloatingList, {
|
|
68
|
-
elementsRef: elementsRef
|
|
69
|
-
}, /*#__PURE__*/React.createElement(DropdownOverlay, {
|
|
70
|
-
size: size,
|
|
71
|
-
triggerRef: triggerRef,
|
|
72
|
-
htmlAttributes: overlayHTMLAttributes,
|
|
73
|
-
overlayStyle: overlayStyle,
|
|
74
|
-
overlayClassName: overlayClassName,
|
|
75
|
-
hideOnItemClick: hideOnItemClick,
|
|
76
|
-
content: overlay,
|
|
77
|
-
handleItemClick: handleItemClick
|
|
78
|
-
})))));
|
|
79
|
-
};
|
|
42
|
+
return /* @__PURE__ */ jsxs(Popover, { placement: floatingPlacement, trigger, modal: false, open, onOpenChange: handleOpenChange, onDismiss, transitionDuration: POPOVER_TRANSITION_DURATION, autoUpdate: true, offsetConfig: POPOVER_OFFSET_CONFIG, flipConfig: POPOVER_FLIP_CONFIG, shiftConfig: POPOVER_SHIFT_CONFIG, getTransitionConfig, getPopupContainer, listNavigationConfig, testId: "dropdown", ...popoverProps, children: [
|
|
43
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { ref: triggerRef, asChild, onClick: handleTriggerClick, ...popoverTriggerProps, children }),
|
|
44
|
+
/* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsx(DropdownContextProvider, { hideOnItemClick, activeIndex, setIsOpen: handleOpenChange, isOpen: !!open, children: /* @__PURE__ */ jsx(FloatingList, { elementsRef, children: /* @__PURE__ */ jsx(DropdownOverlay, { size, triggerRef, htmlAttributes: overlayHTMLAttributes, overlayStyle, overlayClassName, hideOnItemClick, content: overlay, handleItemClick }) }) }) })
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
DropdownPopover
|
|
49
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DropdownProps } from '../../Dropdown.types';
|
|
2
2
|
export type DropdownPopoverProps = Pick<DropdownProps, 'asChild' | 'children' | 'onDismiss' | 'onOpenChange' | 'getPopupContainer' | 'placement' | 'popoverProps' | 'popoverTriggerProps' | 'overlay' | 'overlayClassName' | 'overlayHTMLAttributes' | 'overlayStyle' | 'open' | 'hideOnItemClick' | 'size' | 'trigger'> & {
|
|
3
3
|
handleOpenChange: (newVal: boolean) => void;
|
|
4
4
|
handleItemClick?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TextTriggerProps } from './TextTrigger.types';
|
|
3
3
|
export declare const TextTrigger: React.ForwardRefExoticComponent<TextTriggerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
level: size
|
|
26
|
-
}, value), /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
27
|
-
expanded: expanded
|
|
28
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
29
|
-
component: /*#__PURE__*/React.createElement(AngleDownS, null)
|
|
30
|
-
})));
|
|
31
|
-
});
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import Icon, { AngleDownS } from "@synerise/ds-icon";
|
|
5
|
+
import { Title } from "@synerise/ds-typography";
|
|
6
|
+
import { TextTrigger as TextTrigger$1, IconWrapper } from "./TextTrigger.styles.js";
|
|
7
|
+
const TextTrigger = forwardRef(({
|
|
8
|
+
value,
|
|
9
|
+
expanded,
|
|
10
|
+
size,
|
|
11
|
+
inactiveColor = "grey-800",
|
|
12
|
+
onClick,
|
|
13
|
+
onFocus,
|
|
14
|
+
isDisabled = false
|
|
15
|
+
}, ref) => {
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
return /* @__PURE__ */ jsxs(TextTrigger$1, { onFocus: isDisabled ? void 0 : onFocus, inactiveColor: theme.palette[inactiveColor], tabIndex: 0, ref, onClick: isDisabled ? void 0 : onClick, isDisabled, children: [
|
|
18
|
+
/* @__PURE__ */ jsx(Title, { level: size, children: value }),
|
|
19
|
+
/* @__PURE__ */ jsx(IconWrapper, { expanded, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(AngleDownS, {}) }) })
|
|
20
|
+
] });
|
|
21
|
+
});
|
|
22
|
+
export {
|
|
23
|
+
TextTrigger
|
|
24
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const TextTrigger: import(
|
|
1
|
+
import { ThemeProps } from '@synerise/ds-core';
|
|
2
|
+
export declare const TextTrigger: import('styled-components').StyledComponent<"div", any, {
|
|
3
3
|
inactiveColor: string;
|
|
4
4
|
onFocus?: () => void;
|
|
5
5
|
isDisabled?: boolean;
|
|
6
6
|
}, never>;
|
|
7
|
-
export declare const IconWrapper: import(
|
|
7
|
+
export declare const IconWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
8
8
|
expanded?: boolean;
|
|
9
9
|
} & ThemeProps, never>;
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const TextTrigger = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "TextTriggerstyles__TextTrigger",
|
|
4
4
|
componentId: "sc-xuqby2-0"
|
|
5
|
-
})(["display:flex;flex-direction:row;align-items:center;justify-content:center;cursor:", ";opacity:", ";.ds-title{margin:0;}.ds-title,svg{color:", ";fill:", ";}&&&:focus{.ds-title,svg{color:", ";fill:", ";}}}&:hover{.ds-title,svg{color:", ";fill:", ";}}"],
|
|
6
|
-
|
|
7
|
-
}, function (props) {
|
|
8
|
-
return props.isDisabled ? 0.4 : 1;
|
|
9
|
-
}, function (props) {
|
|
10
|
-
return props.inactiveColor;
|
|
11
|
-
}, function (props) {
|
|
12
|
-
return props.inactiveColor;
|
|
13
|
-
}, function (props) {
|
|
14
|
-
return props.theme.palette['blue-700'];
|
|
15
|
-
}, function (props) {
|
|
16
|
-
return props.theme.palette['blue-700'];
|
|
17
|
-
}, function (props) {
|
|
18
|
-
return props.theme.palette['blue-600'];
|
|
19
|
-
}, function (props) {
|
|
20
|
-
return props.theme.palette['blue-600'];
|
|
21
|
-
});
|
|
22
|
-
export var IconWrapper = styled.div.withConfig({
|
|
5
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:center;cursor:", ";opacity:", ";.ds-title{margin:0;}.ds-title,svg{color:", ";fill:", ";}&&&:focus{.ds-title,svg{color:", ";fill:", ";}}}&:hover{.ds-title,svg{color:", ";fill:", ";}}"], (props) => props.isDisabled ? "default" : "pointer", (props) => props.isDisabled ? 0.4 : 1, (props) => props.inactiveColor, (props) => props.inactiveColor, (props) => props.theme.palette["blue-700"], (props) => props.theme.palette["blue-700"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"]);
|
|
6
|
+
const IconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
23
7
|
displayName: "TextTriggerstyles__IconWrapper",
|
|
24
8
|
componentId: "sc-xuqby2-1"
|
|
25
|
-
})(["&&&{svg{transition:transform 0.1s linear;transform:rotateZ( ", " );}}"],
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
})(["&&&{svg{transition:transform 0.1s linear;transform:rotateZ( ", " );}}"], (props) => props.expanded ? "180deg" : "0deg");
|
|
10
|
+
export {
|
|
11
|
+
IconWrapper,
|
|
12
|
+
TextTrigger
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DropdownMenuTexts } from '../components/DropdownMenu/DropdownMenu.types';
|
|
2
2
|
export declare const useDefaultTexts: (customTexts?: Partial<DropdownMenuTexts>) => DropdownMenuTexts;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
noSearchResults:
|
|
9
|
-
|
|
10
|
-
defaultMessage: "No results"
|
|
11
|
-
}),
|
|
12
|
-
searchClearTooltip: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
13
|
-
id: "DS.CONFIRMATION.SEARCH-CLEAR-TOOLTIP",
|
|
14
|
-
defaultMessage: "Clear"
|
|
15
|
-
}),
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
3
|
+
const useDefaultTexts = (customTexts) => {
|
|
4
|
+
const {
|
|
5
|
+
formatMessage
|
|
6
|
+
} = useIntl();
|
|
7
|
+
return {
|
|
8
|
+
noSearchResults: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.DROPDOWN-MENU.NO-SEARCH-RESULTS", defaultMessage: "No results" }),
|
|
9
|
+
searchClearTooltip: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.CONFIRMATION.SEARCH-CLEAR-TOOLTIP", defaultMessage: "Clear" }),
|
|
16
10
|
searchPlaceholder: formatMessage({
|
|
17
|
-
id:
|
|
18
|
-
defaultMessage:
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
};
|
|
11
|
+
id: "DS.DROPDOWN-MENU.SEARCH-PLACEHOLDER",
|
|
12
|
+
defaultMessage: "Search"
|
|
13
|
+
}),
|
|
14
|
+
...customTexts || {}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
useDefaultTexts
|
|
19
|
+
};
|
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
useEffect(function () {
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
const useDropdownVisibility = ({
|
|
3
|
+
open,
|
|
4
|
+
onOpenChange
|
|
5
|
+
}) => {
|
|
6
|
+
const [internalOpen, setInternalOpen] = useState(open);
|
|
7
|
+
const skipDuplicates = useRef(0);
|
|
8
|
+
const controlledComponent = open !== void 0;
|
|
9
|
+
const actualOpen = controlledComponent ? open : internalOpen;
|
|
10
|
+
useEffect(() => {
|
|
12
11
|
skipDuplicates.current = 0;
|
|
13
12
|
}, [internalOpen]);
|
|
14
|
-
useEffect(
|
|
13
|
+
useEffect(() => {
|
|
15
14
|
if (controlledComponent && open !== internalOpen) {
|
|
16
15
|
if (skipDuplicates.current === 0) {
|
|
17
16
|
skipDuplicates.current += 1;
|
|
18
|
-
onOpenChange
|
|
17
|
+
onOpenChange?.(open);
|
|
19
18
|
}
|
|
20
19
|
setInternalOpen(open);
|
|
21
20
|
}
|
|
22
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
21
|
}, [controlledComponent, open]);
|
|
24
|
-
|
|
22
|
+
const toggleOpen = useCallback((openState) => {
|
|
25
23
|
if (openState !== internalOpen) {
|
|
26
24
|
setInternalOpen(openState);
|
|
27
25
|
}
|
|
28
|
-
// PopupTrigger fires toggleOpen onClick
|
|
29
|
-
// the trigger in the implementation may or may not have an onClick that changes `open` state
|
|
30
|
-
// this prevents duplicated onOpenChange calls if both have onClicks defined
|
|
31
26
|
if (skipDuplicates.current === 0) {
|
|
32
27
|
skipDuplicates.current += 1;
|
|
33
|
-
onOpenChange
|
|
28
|
+
onOpenChange?.(openState);
|
|
34
29
|
}
|
|
35
30
|
}, [internalOpen, onOpenChange]);
|
|
36
31
|
return {
|
|
37
|
-
toggleOpen
|
|
32
|
+
toggleOpen,
|
|
38
33
|
open: actualOpen
|
|
39
34
|
};
|
|
40
|
-
};
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
useDropdownVisibility
|
|
38
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Dropdown, Dropdown as Dropdown2 } from "./Dropdown.js";
|
|
2
|
+
import { DropdownMenu } from "./components/DropdownMenu/DropdownMenu.js";
|
|
3
|
+
import { DropdownOverlay } from "./components/DropdownOverlay/DropdownOverlay.js";
|
|
4
|
+
import { TextTrigger } from "./components/TextTrigger/TextTrigger.js";
|
|
5
|
+
import { BackAction } from "./components/BackAction/BackAction.js";
|
|
6
|
+
import { BottomAction } from "./components/BottomAction/BottomAction.js";
|
|
7
|
+
export {
|
|
8
|
+
BackAction,
|
|
9
|
+
BottomAction,
|
|
10
|
+
Dropdown,
|
|
11
|
+
DropdownMenu,
|
|
12
|
+
DropdownOverlay,
|
|
13
|
+
TextTrigger,
|
|
14
|
+
Dropdown2 as default
|
|
15
|
+
};
|
package/dist/modules.d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DropdownSize } from '../Dropdown.types';
|
|
2
2
|
export declare const getDropdownWidth: (size?: DropdownSize | number) => number | null;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
if (typeof size ===
|
|
1
|
+
const getDropdownWidth = (size) => {
|
|
2
|
+
if (typeof size === "number") {
|
|
3
3
|
return size;
|
|
4
4
|
}
|
|
5
5
|
switch (size) {
|
|
6
|
-
case
|
|
6
|
+
case "small":
|
|
7
7
|
return 216;
|
|
8
|
-
case
|
|
8
|
+
case "large":
|
|
9
9
|
return 588;
|
|
10
|
-
case
|
|
10
|
+
case "medium":
|
|
11
11
|
return 282;
|
|
12
|
-
case
|
|
13
|
-
case
|
|
14
|
-
case
|
|
12
|
+
case "auto":
|
|
13
|
+
case "match-trigger":
|
|
14
|
+
case "min-match-trigger":
|
|
15
15
|
default:
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
};
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
getDropdownWidth
|
|
21
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Placement, UseTransitionStylesProps } from '@floating-ui/react';
|
|
2
2
|
export declare const getTransitionConfig: ({ placement, }: {
|
|
3
3
|
placement: Placement;
|
|
4
4
|
}) => Partial<UseTransitionStylesProps>;
|