@rovula/ui 0.1.35 → 0.1.37
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/cjs/bundle.css +3 -0
- package/dist/cjs/bundle.js +4 -4
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/DropdownMenu/DropdownMenu.d.ts +8 -1
- package/dist/cjs/types/patterns/menu/Menu.d.ts +15 -1
- package/dist/cjs/types/patterns/menu/Menu.stories.d.ts +3 -1
- package/dist/components/Dialog/Dialog.js +6 -1
- package/dist/components/Dialog/Dialog.stories.js +32 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +2 -2
- package/dist/esm/bundle.css +3 -0
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/DropdownMenu/DropdownMenu.d.ts +8 -1
- package/dist/esm/types/patterns/menu/Menu.d.ts +15 -1
- package/dist/esm/types/patterns/menu/Menu.stories.d.ts +3 -1
- package/dist/index.d.ts +23 -2
- package/dist/patterns/menu/Menu.js +5 -5
- package/dist/patterns/menu/Menu.stories.js +20 -0
- package/dist/src/theme/global.css +4 -0
- package/package.json +1 -1
- package/src/components/Dialog/Dialog.stories.tsx +72 -32
- package/src/components/Dialog/Dialog.tsx +6 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +10 -3
- package/src/patterns/menu/Menu.stories.tsx +63 -0
- package/src/patterns/menu/Menu.tsx +19 -1
|
@@ -10,7 +10,14 @@ declare const DropdownMenuSubTrigger: React.ForwardRefExoticComponent<Omit<Dropd
|
|
|
10
10
|
inset?: boolean;
|
|
11
11
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
declare const DropdownMenuSubContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
-
declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> &
|
|
13
|
+
declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
14
|
+
/**
|
|
15
|
+
* DOM element to render the portal into.
|
|
16
|
+
* Pass the dialog's content element when using inside a Dialog to avoid
|
|
17
|
+
* Radix pointer-events conflicts that break hover after re-open.
|
|
18
|
+
*/
|
|
19
|
+
container?: HTMLElement | null;
|
|
20
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
21
|
declare const DropdownMenuItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
15
22
|
inset?: boolean;
|
|
16
23
|
selected?: boolean;
|
|
@@ -16,6 +16,8 @@ export type MenuOption = {
|
|
|
16
16
|
onClick?: () => void;
|
|
17
17
|
/** data-testid attached to the item element */
|
|
18
18
|
testId?: string;
|
|
19
|
+
/** Custom className applied to the item element */
|
|
20
|
+
className?: string;
|
|
19
21
|
};
|
|
20
22
|
export type MenuItemType = {
|
|
21
23
|
type: "item";
|
|
@@ -65,9 +67,21 @@ export type MenuProps = {
|
|
|
65
67
|
contentClassName?: string;
|
|
66
68
|
/** data-testid attached to the menu content element */
|
|
67
69
|
testId?: string;
|
|
70
|
+
/**
|
|
71
|
+
* DOM element to render the dropdown portal into.
|
|
72
|
+
* Pass the dialog's content element when using inside a Dialog to avoid
|
|
73
|
+
* Radix pointer-events conflicts that break hover after re-open.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const [container, setContainer] = React.useState<HTMLDivElement | null>(null);
|
|
77
|
+
* <DialogContent ref={setContainer}>
|
|
78
|
+
* <Menu container={container} ... />
|
|
79
|
+
* </DialogContent>
|
|
80
|
+
*/
|
|
81
|
+
container?: HTMLElement | null;
|
|
68
82
|
};
|
|
69
83
|
export declare const Menu: {
|
|
70
|
-
({ trigger, items, selectedValues, onSelect, header, open, onOpenChange, align, side, sideOffset, contentClassName, testId, }: MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
({ trigger, items, selectedValues, onSelect, header, open, onOpenChange, align, side, sideOffset, contentClassName, testId, container, }: MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
71
85
|
displayName: string;
|
|
72
86
|
};
|
|
73
87
|
export { DropdownMenuItem as MenuItem, DropdownMenuSeparator as MenuSeparator, DropdownMenuLabel as MenuLabel, } from "../../components/DropdownMenu/DropdownMenu";
|
|
@@ -4,7 +4,7 @@ import { Menu, MenuItemType } from "./Menu";
|
|
|
4
4
|
declare const meta: {
|
|
5
5
|
title: string;
|
|
6
6
|
component: {
|
|
7
|
-
({ trigger, items, selectedValues, onSelect, header, open, onOpenChange, align, side, sideOffset, contentClassName, testId, }: import("./Menu").MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
({ trigger, items, selectedValues, onSelect, header, open, onOpenChange, align, side, sideOffset, contentClassName, testId, container, }: import("./Menu").MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
displayName: string;
|
|
9
9
|
};
|
|
10
10
|
parameters: {
|
|
@@ -23,6 +23,7 @@ declare const meta: {
|
|
|
23
23
|
sideOffset?: number | undefined;
|
|
24
24
|
contentClassName?: string | undefined;
|
|
25
25
|
testId?: string | undefined;
|
|
26
|
+
container?: (HTMLElement | null) | undefined;
|
|
26
27
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
27
28
|
};
|
|
28
29
|
export default meta;
|
|
@@ -37,3 +38,4 @@ export declare const ComplexMenu: StoryObj<typeof Menu>;
|
|
|
37
38
|
export declare const MultiSelectPattern: StoryObj<typeof Menu>;
|
|
38
39
|
export declare const ChangeStatus: StoryObj<typeof Menu>;
|
|
39
40
|
export declare const ManageColumn: StoryObj<typeof Menu>;
|
|
41
|
+
export declare const InsideDialog: StoryObj<typeof Menu>;
|
|
@@ -26,7 +26,12 @@ const DialogOverlay = React.forwardRef((_a, ref) => {
|
|
|
26
26
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
27
27
|
const DialogContent = React.forwardRef((_a, ref) => {
|
|
28
28
|
var { className, children, showCloseButton = false, closeButtonClassName } = _a, props = __rest(_a, ["className", "children", "showCloseButton", "closeButtonClassName"]);
|
|
29
|
-
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn("fixed left-[50%] top-[50%] z-50 flex w-[calc(100%-32px)] max-w-[650px] translate-x-[-50%] translate-y-[-50%] flex-col gap-6 rounded-md bg-modal-surface p-8 text-text-g-contrast-medium shadow-[0px_12px_24px_-4px_rgba(0,0,0,0.12)] duration-200 focus:outline-none focus-visible:outline-none outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]", className) }, props, {
|
|
29
|
+
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn("fixed left-[50%] top-[50%] z-50 flex w-[calc(100%-32px)] max-w-[650px] translate-x-[-50%] translate-y-[-50%] flex-col gap-6 rounded-md bg-modal-surface p-8 text-text-g-contrast-medium shadow-[0px_12px_24px_-4px_rgba(0,0,0,0.12)] duration-200 focus:outline-none focus-visible:outline-none outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]", className) }, props, { onCloseAutoFocus: (event) => {
|
|
30
|
+
var _a;
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
document.body.style.pointerEvents = "auto";
|
|
33
|
+
(_a = props === null || props === void 0 ? void 0 : props.onCloseAutoFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
34
|
+
}, children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { className: cn("absolute right-8 top-8 rounded-sm opacity-70 ring-offset-bg-bg1 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-input-active-stroke focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-primary data-[state=open]:text-state-primary-text-solid", closeButtonClassName), children: [_jsx(XMarkIcon, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Close" })] }))] }))] }));
|
|
30
35
|
});
|
|
31
36
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
32
37
|
const DialogHeader = (_a) => {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
import * as yup from "yup";
|
|
3
4
|
import { Dialog, DialogContent, DialogDescription, DialogBody, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "./Dialog";
|
|
4
5
|
import Button from "../Button/Button";
|
|
5
6
|
import { Label } from "../Label/Label";
|
|
6
7
|
import { Input } from "../Input/Input";
|
|
8
|
+
import { Menu } from "@/patterns/menu/Menu";
|
|
7
9
|
const meta = {
|
|
8
10
|
title: "Components/Dialog",
|
|
9
11
|
component: Dialog,
|
|
@@ -97,5 +99,34 @@ export const FigmaFunctionForm = {
|
|
|
97
99
|
render: () => (_jsx("div", { className: "flex w-full", children: _jsx(Dialog, { defaultOpen: true, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Title" }), _jsx(DialogDescription, { children: "Subtitle description" })] }), _jsx(DialogBody, { children: _jsx("div", { className: "flex items-center justify-center bg-ramps-secondary-150 h-[200px] w-full rounded-sm", children: _jsx("p", { className: "typography-body3 text-text-contrast-max", children: "Content - Form Area" }) }) }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", color: "primary", fullwidth: false, children: "Cancel" }), _jsx(Button, { disabled: true, fullwidth: false, children: "Confirm" })] })] }) }) })),
|
|
98
100
|
};
|
|
99
101
|
export const FigmaFunctionFormWithAction = {
|
|
100
|
-
render: () =>
|
|
102
|
+
render: () => {
|
|
103
|
+
const [open, setOpen] = useState(false);
|
|
104
|
+
const handleOpenChange = (open) => {
|
|
105
|
+
setOpen(open);
|
|
106
|
+
};
|
|
107
|
+
const handleCancel = () => {
|
|
108
|
+
setOpen(false);
|
|
109
|
+
};
|
|
110
|
+
const handleConfirm = () => {
|
|
111
|
+
setOpen(false);
|
|
112
|
+
};
|
|
113
|
+
return (_jsxs("div", { className: "flex w-full", children: [_jsx(Menu, { items: [
|
|
114
|
+
{
|
|
115
|
+
type: "item",
|
|
116
|
+
item: {
|
|
117
|
+
value: "edit",
|
|
118
|
+
label: "Edit",
|
|
119
|
+
onClick: () => handleOpenChange(true),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "item",
|
|
124
|
+
item: {
|
|
125
|
+
value: "delete",
|
|
126
|
+
label: "Delete",
|
|
127
|
+
onClick: () => handleOpenChange(true),
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
], trigger: _jsx(Button, { variant: "outline", children: "Open" }) }), _jsx(Dialog, { open: open, onOpenChange: handleOpenChange, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Title" }), _jsx(DialogDescription, { children: "Subtitle description" })] }), _jsx(DialogBody, { children: _jsx("div", { className: "flex items-center justify-center bg-ramps-secondary-150 h-[200px] w-full rounded-sm", children: _jsx("p", { className: "typography-body3 text-text-contrast-max", children: "Content - Form Area" }) }) }), _jsxs(DialogFooter, { className: "justify-between", children: [_jsx(Button, { variant: "outline", color: "secondary", fullwidth: false, children: "Medium" }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Button, { variant: "outline", color: "primary", fullwidth: false, onClick: handleCancel, children: "Cancel" }), _jsx(Button, { disabled: true, fullwidth: false, onClick: handleConfirm, children: "Confirm" })] })] })] }) })] }));
|
|
131
|
+
},
|
|
101
132
|
};
|
|
@@ -34,8 +34,8 @@ const DropdownMenuSubContent = React.forwardRef((_a, ref) => {
|
|
|
34
34
|
DropdownMenuSubContent.displayName =
|
|
35
35
|
DropdownMenuPrimitive.SubContent.displayName;
|
|
36
36
|
const DropdownMenuContent = React.forwardRef((_a, ref) => {
|
|
37
|
-
var { className, sideOffset = 4 } = _a, props = __rest(_a, ["className", "sideOffset"]);
|
|
38
|
-
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, Object.assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-modal-surface text-text-contrast-low data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props, { style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, props.style) })) }));
|
|
37
|
+
var { className, sideOffset = 4, container } = _a, props = __rest(_a, ["className", "sideOffset", "container"]);
|
|
38
|
+
return (_jsx(DropdownMenuPrimitive.Portal, { container: container, children: _jsx(DropdownMenuPrimitive.Content, Object.assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-modal-surface text-text-contrast-low data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props, { style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, props.style) })) }));
|
|
39
39
|
});
|
|
40
40
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
41
41
|
const DropdownMenuItem = React.forwardRef((_a, ref) => {
|