@povio/ui 2.1.16 → 2.1.17
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/BottomSheet.js +2 -1
- package/dist/Drawer.js +10 -2
- package/dist/MenuDesktop.js +2 -1
- package/dist/MenuMobile.js +25 -13
- package/dist/MenuPopover.js +22 -10
- package/dist/Modal.js +5 -1
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/Menu/MenuDesktop.d.ts +1 -1
- package/dist/components/Menu/MenuMobile.d.ts +1 -1
- package/dist/components/Menu/MenuPopover.d.ts +2 -2
- package/dist/components/overlays/BottomSheet/BottomSheet.d.ts +1 -0
- package/dist/components/overlays/Drawer/Drawer.d.ts +3 -1
- package/dist/components/overlays/Modal/Modal.d.ts +2 -1
- package/dist/config/i18n.d.ts +1 -0
- package/dist/error-handling.js +14 -2
- package/dist/translation.js +2 -1
- package/package.json +1 -1
package/dist/BottomSheet.js
CHANGED
|
@@ -22,7 +22,7 @@ var staticTransition = {
|
|
|
22
22
|
1
|
|
23
23
|
]
|
|
24
24
|
};
|
|
25
|
-
var BottomSheetBase = ({ isOpen, onOpenChange, onStateChange, isDismissable = false, isScrollable = true, height = "full", label, portalContainerRef, children, footer, sheetMarginTop = 96, sheetMarginBottom = 128 }) => {
|
|
25
|
+
var BottomSheetBase = ({ isOpen, onOpenChange, onStateChange, isDismissable = false, isScrollable = true, height = "full", label, portalContainerRef, children, footer, sheetMarginTop = 96, sheetMarginBottom = 128, shouldCloseOnInteractOutside }) => {
|
|
26
26
|
const viewport = useViewportSize();
|
|
27
27
|
const { sheetHeight, windowHeight } = useMemo(() => {
|
|
28
28
|
return {
|
|
@@ -65,6 +65,7 @@ var BottomSheetBase = ({ isOpen, onOpenChange, onStateChange, isDismissable = fa
|
|
|
65
65
|
isDismissable,
|
|
66
66
|
style: { height: viewport.height },
|
|
67
67
|
ref: overlayRef,
|
|
68
|
+
shouldCloseOnInteractOutside,
|
|
68
69
|
children: [/* @__PURE__ */ jsx(react_exports.motion.div, {
|
|
69
70
|
className: "pointer-events-none absolute inset-0 bg-support-overlay",
|
|
70
71
|
animate: { opacity: 1 },
|
package/dist/Drawer.js
CHANGED
|
@@ -2,16 +2,18 @@ import { modalOverlay } from "./modal.cva.js";
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
4
|
import { Dialog, DialogTrigger, Modal, ModalOverlay } from "react-aria-components";
|
|
5
|
-
const Drawer = ({ isOpen, portalContainerRef, onOpenChange, trigger, children, isDismissable, overlayClassName, dialogClassName, className }) => {
|
|
5
|
+
const Drawer = ({ label, isOpen, portalContainerRef, onOpenChange, trigger, children, isDismissable, overlayClassName, dialogClassName, className, shouldCloseOnInteractOutside }) => {
|
|
6
6
|
if (trigger) return /* @__PURE__ */ jsxs(DialogTrigger, {
|
|
7
7
|
isOpen,
|
|
8
8
|
onOpenChange,
|
|
9
9
|
children: [trigger, /* @__PURE__ */ jsx(DrawerOverlay, {
|
|
10
|
+
label,
|
|
10
11
|
portalContainerRef,
|
|
11
12
|
isDismissable,
|
|
12
13
|
overlayClassName,
|
|
13
14
|
dialogClassName,
|
|
14
15
|
className,
|
|
16
|
+
shouldCloseOnInteractOutside,
|
|
15
17
|
children
|
|
16
18
|
})]
|
|
17
19
|
});
|
|
@@ -20,20 +22,26 @@ const Drawer = ({ isOpen, portalContainerRef, onOpenChange, trigger, children, i
|
|
|
20
22
|
onOpenChange,
|
|
21
23
|
portalContainerRef,
|
|
22
24
|
isDismissable,
|
|
25
|
+
overlayClassName,
|
|
26
|
+
dialogClassName,
|
|
23
27
|
className,
|
|
28
|
+
label,
|
|
29
|
+
shouldCloseOnInteractOutside,
|
|
24
30
|
children
|
|
25
31
|
});
|
|
26
32
|
};
|
|
27
|
-
var DrawerOverlay = ({ isOpen, onOpenChange, portalContainerRef, children, isDismissable, overlayClassName, dialogClassName, className }) => {
|
|
33
|
+
var DrawerOverlay = ({ label, isOpen, onOpenChange, portalContainerRef, children, isDismissable, overlayClassName, dialogClassName, className, shouldCloseOnInteractOutside }) => {
|
|
28
34
|
return /* @__PURE__ */ jsx(ModalOverlay, {
|
|
29
35
|
isOpen,
|
|
30
36
|
onOpenChange,
|
|
31
37
|
UNSTABLE_portalContainer: portalContainerRef?.current,
|
|
32
38
|
className: clsx(modalOverlay(), overlayClassName),
|
|
33
39
|
isDismissable,
|
|
40
|
+
shouldCloseOnInteractOutside,
|
|
34
41
|
children: /* @__PURE__ */ jsx(Modal, {
|
|
35
42
|
className: clsx("fixed inset-y-0 right-0 z-10 w-fit entering:animate-drawer-enter-right exiting:animate-drawer-exit-right bg-elevation-fill-default-1", className),
|
|
36
43
|
children: /* @__PURE__ */ jsx(Dialog, {
|
|
44
|
+
"aria-label": label,
|
|
37
45
|
className: clsx("outline-none", dialogClassName),
|
|
38
46
|
children: ({ close }) => children(close)
|
|
39
47
|
})
|
package/dist/MenuDesktop.js
CHANGED
|
@@ -4,7 +4,7 @@ import { MenuTrigger } from "react-aria-components";
|
|
|
4
4
|
import React, { useRef, useState } from "react";
|
|
5
5
|
import { useHover } from "react-aria";
|
|
6
6
|
var CLOSE_DELAY = 100;
|
|
7
|
-
const MenuDesktop = ({ trigger, items, closeDelay = CLOSE_DELAY, triggerOnHover = false,...props }) => {
|
|
7
|
+
const MenuDesktop = ({ trigger, items, closeDelay = CLOSE_DELAY, triggerOnHover = false, onAction,...props }) => {
|
|
8
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
9
9
|
const timeoutRef = useRef(null);
|
|
10
10
|
const isHoveringTrigger = useRef(false);
|
|
@@ -43,6 +43,7 @@ const MenuDesktop = ({ trigger, items, closeDelay = CLOSE_DELAY, triggerOnHover
|
|
|
43
43
|
...props,
|
|
44
44
|
offset: 0,
|
|
45
45
|
items,
|
|
46
|
+
onAction,
|
|
46
47
|
isOpen: triggerOnHover ? isOpen : void 0,
|
|
47
48
|
isNonModal: triggerOnHover,
|
|
48
49
|
onMouseEnter: triggerOnHover ? openMenu : void 0,
|
package/dist/MenuMobile.js
CHANGED
|
@@ -7,20 +7,24 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { Button, Menu } from "react-aria-components";
|
|
9
9
|
import { useRef, useState } from "react";
|
|
10
|
-
const MenuMobile = ({ trigger, items,...props }) => {
|
|
10
|
+
const MenuMobile = ({ trigger, items, onAction,...props }) => {
|
|
11
11
|
const uiStyle = UIStyle.useConfig();
|
|
12
12
|
const menuItemCva$1 = uiStyle?.menu?.itemCva ?? menuItemCva;
|
|
13
13
|
const menuCva$1 = uiStyle?.menu?.cva ?? menuCva;
|
|
14
14
|
const activeItemRef = useRef(null);
|
|
15
15
|
const activeItemParentsRef = useRef([]);
|
|
16
|
+
const lastEventRef = useRef(null);
|
|
16
17
|
const [isOpen, setIsOpen] = useState(false);
|
|
17
18
|
const [activeItem, setActiveItem] = useState(null);
|
|
18
|
-
const
|
|
19
|
+
const handleAction = (item) => {
|
|
19
20
|
if (!item.children) {
|
|
20
21
|
activeItemRef.current = null;
|
|
21
22
|
activeItemParentsRef.current = [];
|
|
22
23
|
setActiveItem(null);
|
|
23
24
|
setIsOpen(false);
|
|
25
|
+
item.onAction?.();
|
|
26
|
+
onAction?.(item.id, lastEventRef.current);
|
|
27
|
+
lastEventRef.current = null;
|
|
24
28
|
return;
|
|
25
29
|
}
|
|
26
30
|
if (activeItemRef.current) activeItemParentsRef.current.push(activeItemRef.current);
|
|
@@ -47,17 +51,25 @@ const MenuMobile = ({ trigger, items,...props }) => {
|
|
|
47
51
|
})),
|
|
48
52
|
onPress: onBack,
|
|
49
53
|
children: [/* @__PURE__ */ jsx(ArrowLeftIcon, { className: "size-6" }), activeItem.label]
|
|
50
|
-
}), /* @__PURE__ */ jsx(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
children:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
55
|
+
onClickCapture: (e) => {
|
|
56
|
+
lastEventRef.current = e;
|
|
57
|
+
},
|
|
58
|
+
onKeyDownCapture: (e) => {
|
|
59
|
+
lastEventRef.current = e;
|
|
60
|
+
},
|
|
61
|
+
children: /* @__PURE__ */ jsx(Menu, {
|
|
62
|
+
autoFocus: true,
|
|
63
|
+
onClose,
|
|
64
|
+
className: menuCva$1({
|
|
65
|
+
...props,
|
|
66
|
+
isMobile: true
|
|
67
|
+
}),
|
|
68
|
+
children: (activeItem?.children ?? items).map((item, index) => /* @__PURE__ */ jsx(MenuItem$1, {
|
|
69
|
+
...item,
|
|
70
|
+
onAction: () => handleAction(item)
|
|
71
|
+
}, index))
|
|
72
|
+
})
|
|
61
73
|
})] })
|
|
62
74
|
});
|
|
63
75
|
};
|
package/dist/MenuPopover.js
CHANGED
|
@@ -4,7 +4,9 @@ import { MenuItem as MenuItem$1 } from "./MenuItem.js";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { clsx } from "clsx";
|
|
6
6
|
import { Menu, Popover, SubmenuTrigger } from "react-aria-components";
|
|
7
|
-
|
|
7
|
+
import { useRef } from "react";
|
|
8
|
+
const MenuPopover = ({ items, className, onAction,...props }) => {
|
|
9
|
+
const lastEventRef = useRef(null);
|
|
8
10
|
const uiStyle = UIStyle.useConfig();
|
|
9
11
|
const menuPopoverCva$1 = uiStyle?.menu?.popoverCva ?? menuPopoverCva;
|
|
10
12
|
const menuPopoverWrapperCva$1 = uiStyle?.menu?.popoverWrapperCva ?? menuPopoverWrapperCva;
|
|
@@ -14,15 +16,25 @@ const MenuPopover = ({ items, className,...props }) => {
|
|
|
14
16
|
className: clsx(menuPopoverCva$1({ ...props }), className),
|
|
15
17
|
children: /* @__PURE__ */ jsx("div", {
|
|
16
18
|
className: menuPopoverWrapperCva$1({ ...props }),
|
|
17
|
-
children: /* @__PURE__ */ jsx(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
20
|
+
onClickCapture: (e) => {
|
|
21
|
+
lastEventRef.current = e;
|
|
22
|
+
},
|
|
23
|
+
onKeyDownCapture: (e) => {
|
|
24
|
+
lastEventRef.current = e;
|
|
25
|
+
},
|
|
26
|
+
children: /* @__PURE__ */ jsx(Menu, {
|
|
27
|
+
onAction: (key) => onAction?.(key, lastEventRef.current),
|
|
28
|
+
className: menuCva$1({
|
|
29
|
+
...props,
|
|
30
|
+
isMobile: false
|
|
31
|
+
}),
|
|
32
|
+
children: items.map((item, index) => !item.children || item.children.length === 0 ? /* @__PURE__ */ jsx(MenuItem$1, { ...item }, index) : /* @__PURE__ */ jsxs(SubmenuTrigger, { children: [/* @__PURE__ */ jsx(MenuItem$1, { ...item }), /* @__PURE__ */ jsx(MenuPopover, {
|
|
33
|
+
offset: 0,
|
|
34
|
+
onAction,
|
|
35
|
+
items: item.children
|
|
36
|
+
})] }, index))
|
|
37
|
+
})
|
|
26
38
|
})
|
|
27
39
|
})
|
|
28
40
|
});
|
package/dist/Modal.js
CHANGED
|
@@ -7,7 +7,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { Dialog, Modal, ModalOverlay } from "react-aria-components";
|
|
9
9
|
import { useTranslation } from "react-i18next";
|
|
10
|
-
const Modal$1 = ({ isOpen, portalContainerRef, onClose, aside, children, modalClassName, closeIconClassName, overlayClassName, showCloseIcon, isDismissable = true }) => {
|
|
10
|
+
const Modal$1 = ({ isOpen, portalContainerRef, onClose, aside, children, modalClassName, closeIconClassName, overlayClassName, showCloseIcon, isDismissable = true, shouldCloseOnInteractOutside }) => {
|
|
11
11
|
const { t } = useTranslation("ui");
|
|
12
12
|
const uiStyle = UIStyle.useConfig();
|
|
13
13
|
const modalMainCva = uiStyle?.modal?.mainCva ?? modalMain;
|
|
@@ -22,6 +22,10 @@ const Modal$1 = ({ isOpen, portalContainerRef, onClose, aside, children, modalCl
|
|
|
22
22
|
isDismissable,
|
|
23
23
|
isOpen,
|
|
24
24
|
shouldCloseOnInteractOutside: () => {
|
|
25
|
+
if (shouldCloseOnInteractOutside) {
|
|
26
|
+
if (portalContainerRef?.current) return false;
|
|
27
|
+
return shouldCloseOnInteractOutside();
|
|
28
|
+
}
|
|
25
29
|
return !portalContainerRef?.current;
|
|
26
30
|
},
|
|
27
31
|
onOpenChange: (open) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import { Key, ReactElement } from 'react';
|
|
2
2
|
import { MenuItemProps } from 'react-aria-components';
|
|
3
3
|
import { MenuCvaVariantProps, MenuItemVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps } from './menu.cva';
|
|
4
4
|
export interface MenuItem extends Omit<MenuItemProps, "aria-label" | "textValue" | "children">, MenuItemVariantProps, MenuCvaVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps {
|
|
@@ -11,5 +11,6 @@ export interface MenuProps {
|
|
|
11
11
|
items: MenuItem[];
|
|
12
12
|
triggerOnHover?: boolean;
|
|
13
13
|
closeDelay?: number;
|
|
14
|
+
onAction?: (key: Key, e: any) => void;
|
|
14
15
|
}
|
|
15
16
|
export declare const Menu: (props: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MenuProps } from './Menu';
|
|
2
|
-
export declare const MenuDesktop: ({ trigger, items, closeDelay, triggerOnHover, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const MenuDesktop: ({ trigger, items, closeDelay, triggerOnHover, onAction, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MenuProps } from './Menu';
|
|
2
|
-
export declare const MenuMobile: ({ trigger, items, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const MenuMobile: ({ trigger, items, onAction, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PopoverProps as AriaPopoverProps } from 'react-aria-components';
|
|
2
2
|
import { MenuProps } from './Menu';
|
|
3
|
-
export interface MenuPopoverProps extends Pick<MenuProps, "items">, AriaPopoverProps {
|
|
3
|
+
export interface MenuPopoverProps extends Pick<MenuProps, "items" | "onAction">, AriaPopoverProps {
|
|
4
4
|
}
|
|
5
|
-
export declare const MenuPopover: ({ items, className, ...props }: MenuPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const MenuPopover: ({ items, className, onAction, ...props }: MenuPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from 'react';
|
|
2
2
|
export interface DrawerProps {
|
|
3
|
+
label: string;
|
|
3
4
|
isOpen?: boolean;
|
|
4
5
|
portalContainerRef?: RefObject<HTMLElement>;
|
|
5
6
|
onOpenChange?: (isOpen: boolean) => void;
|
|
@@ -9,5 +10,6 @@ export interface DrawerProps {
|
|
|
9
10
|
overlayClassName?: string;
|
|
10
11
|
dialogClassName?: string;
|
|
11
12
|
className?: string;
|
|
13
|
+
shouldCloseOnInteractOutside?: () => boolean;
|
|
12
14
|
}
|
|
13
|
-
export declare const Drawer: ({ isOpen, portalContainerRef, onOpenChange, trigger, children, isDismissable, overlayClassName, dialogClassName, className, }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const Drawer: ({ label, isOpen, portalContainerRef, onOpenChange, trigger, children, isDismissable, overlayClassName, dialogClassName, className, shouldCloseOnInteractOutside, }: DrawerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,5 +9,6 @@ export interface ModalProps extends ModalVariantProps {
|
|
|
9
9
|
overlayClassName?: string;
|
|
10
10
|
showCloseIcon?: boolean;
|
|
11
11
|
isDismissable?: boolean;
|
|
12
|
+
shouldCloseOnInteractOutside?: () => boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare const Modal: ({ isOpen, portalContainerRef, onClose, aside, children, modalClassName, closeIconClassName, overlayClassName, showCloseIcon, isDismissable, }: PropsWithChildren<ModalProps>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const Modal: ({ isOpen, portalContainerRef, onClose, aside, children, modalClassName, closeIconClassName, overlayClassName, showCloseIcon, isDismissable, shouldCloseOnInteractOutside, }: PropsWithChildren<ModalProps>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/config/i18n.d.ts
CHANGED
package/dist/error-handling.js
CHANGED
|
@@ -50,7 +50,13 @@ var ErrorHandler = class {
|
|
|
50
50
|
const unknownError = {
|
|
51
51
|
code: "UNKNOWN_ERROR",
|
|
52
52
|
condition: () => true,
|
|
53
|
-
getMessage: () =>
|
|
53
|
+
getMessage: (e) => {
|
|
54
|
+
if (axios.isAxiosError(e) && e.response?.data?.code) return i18next.t(($) => $.sharedErrors.unknownErrorWithCode, {
|
|
55
|
+
ns: "ui",
|
|
56
|
+
code: e.response.data.code
|
|
57
|
+
});
|
|
58
|
+
return i18next.t(($) => $.sharedErrors.unknownError, { ns: "ui" });
|
|
59
|
+
}
|
|
54
60
|
};
|
|
55
61
|
this.entries = [
|
|
56
62
|
...entries,
|
|
@@ -79,7 +85,13 @@ var ErrorHandler = class {
|
|
|
79
85
|
if (typeof error === "string") return error;
|
|
80
86
|
if (error instanceof Error) return error.message;
|
|
81
87
|
if (error instanceof ApplicationException) return error.message;
|
|
82
|
-
if (fallbackToUnknown)
|
|
88
|
+
if (fallbackToUnknown) {
|
|
89
|
+
if (error && typeof error === "object" && "code" in error) return i18next.t(($) => $.sharedErrors.unknownErrorWithCode, {
|
|
90
|
+
ns: "ui",
|
|
91
|
+
code: error.code
|
|
92
|
+
});
|
|
93
|
+
return i18next.t(($) => $.sharedErrors.unknownError, { ns: "ui" });
|
|
94
|
+
}
|
|
83
95
|
return null;
|
|
84
96
|
}
|
|
85
97
|
};
|
package/dist/translation.js
CHANGED
|
@@ -141,7 +141,8 @@ var translation_default = {
|
|
|
141
141
|
"internalError": "An internal error occurred. This is most likely a bug on our end. Please try again later.",
|
|
142
142
|
"networkError": "A network error occurred. Are you connected to the internet?",
|
|
143
143
|
"canceledError": "The request was canceled.",
|
|
144
|
-
"unknownError": "An unknown error occurred.
|
|
144
|
+
"unknownError": "An unknown error occurred.",
|
|
145
|
+
"unknownErrorWithCode": "An unknown error occurred. Error code: \"{{code}}\""
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
148
|
export { translation_default as default };
|