@payfit/unity-components 3.23.24 → 3.23.26
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/esm/core/components/menu/Menu.context.d.ts +9 -0
- package/dist/esm/core/components/menu/Menu.context.js +15 -0
- package/dist/esm/core/components/menu/Menu.d.ts +49 -4
- package/dist/esm/core/components/menu/Menu.js +21 -18
- package/dist/esm/core/components/menu/menu.variants.d.ts +1 -0
- package/dist/esm/core/components/menu/menu.variants.js +9 -0
- package/dist/esm/core/components/menu/parts/MenuContent.d.ts +42 -5
- package/dist/esm/core/components/menu/parts/MenuContent.js +19 -14
- package/dist/esm/core/components/menu/parts/MenuHeader.d.ts +12 -2
- package/dist/esm/core/components/menu/parts/MenuHeader.js +13 -11
- package/dist/esm/core/components/menu/parts/MenuSection.d.ts +10 -4
- package/dist/esm/core/components/menu/parts/MenuSection.js +46 -27
- package/dist/esm/core/components/menu/parts/MenuSeparator.d.ts +6 -0
- package/dist/esm/core/components/menu/parts/MenuSeparator.js +1 -1
- package/dist/esm/core/components/menu/parts/MenuSubmenu.d.ts +45 -0
- package/dist/esm/core/components/menu/parts/MenuSubmenu.js +22 -0
- package/dist/esm/core/components/menu/parts/MenuTrigger.d.ts +23 -2
- package/dist/esm/core/components/menu/parts/RawMenuItem.d.ts +46 -3
- package/dist/esm/core/components/menu/parts/RawMenuItem.js +71 -30
- package/dist/esm/core/index.d.ts +1 -0
- package/dist/esm/core/index.js +93 -92
- package/dist/esm/index.js +106 -105
- package/package.json +6 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
interface MenuContextValue {
|
|
3
|
+
compact: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function MenuProvider({ children, compact, }: PropsWithChildren<{
|
|
6
|
+
compact?: boolean;
|
|
7
|
+
}>): import('react/jsx-runtime').JSX.Element;
|
|
8
|
+
export declare function useMenuContext(): MenuContextValue;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/core/components/menu/Menu.context.tsx
|
|
4
|
+
var r = e({ compact: !1 });
|
|
5
|
+
function i({ children: e, compact: t = !1 }) {
|
|
6
|
+
return /* @__PURE__ */ n(r.Provider, {
|
|
7
|
+
value: { compact: t },
|
|
8
|
+
children: e
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function a() {
|
|
12
|
+
return t(r);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { i as MenuProvider, a as useMenuContext };
|
|
@@ -1,12 +1,57 @@
|
|
|
1
1
|
import { MenuTriggerProps } from 'react-aria-components/Menu';
|
|
2
2
|
import { PopoverProps } from 'react-aria-components/Popover';
|
|
3
|
-
|
|
3
|
+
export interface MenuProps extends Omit<MenuTriggerProps, 'className' | 'style'> {
|
|
4
|
+
/** Renders all menu content with a denser spacing treatment. */
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
/** Positions the menu popover relative to its trigger. */
|
|
4
7
|
placement?: PopoverProps['placement'];
|
|
8
|
+
/** Adds classes to the Unity popover that wraps the menu content. */
|
|
5
9
|
popoverClassName?: string;
|
|
10
|
+
/** Forwards a ref to the element used to position the popover. */
|
|
6
11
|
triggerRef?: PopoverProps['triggerRef'];
|
|
7
|
-
}
|
|
8
|
-
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gives people a keyboard-accessible list of actions or navigation choices.
|
|
15
|
+
*
|
|
16
|
+
* Compose `Menu` with exactly two children: a `MenuTrigger` and a
|
|
17
|
+
* `MenuContent`. React Aria manages opening, focus restoration, keyboard
|
|
18
|
+
* navigation, and dismissal while Unity supplies the menu surface and item
|
|
19
|
+
* styling.
|
|
20
|
+
* @param props - Trigger behavior, popover positioning, and menu content.
|
|
21
|
+
* @param props.children - A `MenuTrigger` followed by a `MenuContent`.
|
|
22
|
+
* @param props.compact - Renders all menu content with compact spacing.
|
|
23
|
+
* @param props.defaultOpen - Opens the menu when it first renders.
|
|
24
|
+
* @param props.placement - Positions the menu relative to its trigger.
|
|
25
|
+
* @param props.popoverClassName - Adds classes to the menu popover.
|
|
26
|
+
* @param props.triggerRef - Forwards a ref to the popover positioning element.
|
|
27
|
+
* @see {@link MenuProps} for all available props.
|
|
28
|
+
* @see {@link MenuSubmenu} for nested action menus.
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import {
|
|
32
|
+
* Menu,
|
|
33
|
+
* MenuContent,
|
|
34
|
+
* MenuTrigger,
|
|
35
|
+
* RawMenuItem,
|
|
36
|
+
* } from '@payfit/unity-components'
|
|
37
|
+
*
|
|
38
|
+
* export function ActionsMenu() {
|
|
39
|
+
* return (
|
|
40
|
+
* <Menu>
|
|
41
|
+
* <MenuTrigger>Actions</MenuTrigger>
|
|
42
|
+
* <MenuContent>
|
|
43
|
+
* <RawMenuItem onAction={() => console.log('Save')}>Save</RawMenuItem>
|
|
44
|
+
* <RawMenuItem href="/settings">Settings</RawMenuItem>
|
|
45
|
+
* </MenuContent>
|
|
46
|
+
* </Menu>
|
|
47
|
+
* )
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
* @remarks
|
|
51
|
+
* Keep the trigger and content as direct children of `Menu`. Use
|
|
52
|
+
* `MenuSubmenu` inside `MenuContent` instead of nesting a second `Menu`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function Menu({ defaultOpen, compact, children, popoverClassName, triggerRef, placement, ...rest }: MenuProps): import('react/jsx-runtime').JSX.Element;
|
|
9
55
|
export declare namespace Menu {
|
|
10
56
|
var displayName: string;
|
|
11
57
|
}
|
|
12
|
-
export {};
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { MenuProvider as e } from "./Menu.context.js";
|
|
2
|
+
import { menuPopover as t } from "./menu.variants.js";
|
|
3
|
+
import n from "react";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
import { MenuTrigger as a, Popover as o } from "react-aria-components/Menu";
|
|
5
6
|
//#region src/core/components/menu/Menu.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
function s({ defaultOpen: s, compact: c = !1, children: l, popoverClassName: u, triggerRef: d, placement: f, ...p }) {
|
|
8
|
+
let [m, h] = n.Children.toArray(l);
|
|
9
|
+
if (!m || !h) throw Error("Menu must have a trigger and a menu content");
|
|
10
|
+
return /* @__PURE__ */ r(e, {
|
|
11
|
+
compact: c,
|
|
12
|
+
children: /* @__PURE__ */ i(a, {
|
|
13
|
+
defaultOpen: s,
|
|
14
|
+
...p,
|
|
15
|
+
children: [m, /* @__PURE__ */ r(o, {
|
|
16
|
+
triggerRef: d,
|
|
17
|
+
placement: f,
|
|
18
|
+
className: t({ className: u }),
|
|
19
|
+
"data-dd-privacy": "allow",
|
|
20
|
+
children: h
|
|
21
|
+
})]
|
|
22
|
+
})
|
|
20
23
|
});
|
|
21
24
|
}
|
|
22
25
|
s.displayName = "Menu";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const menuPopover: import('tailwind-variants').TVReturnType<{} | {} | {}, undefined, string[], {} | {}, undefined, import('tailwind-variants').TVReturnTypeLike<unknown, undefined>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { uyTv as e } from "@payfit/unity-themes";
|
|
2
|
+
//#region src/core/components/menu/menu.variants.ts
|
|
3
|
+
var t = e({ base: [
|
|
4
|
+
"uy:flex uy:flex-col uy:justify-start uy:items-start uy:p-100",
|
|
5
|
+
"uy:max-h-[var(--popover-available-height,100dvh)] uy:overflow-x-hidden uy:overflow-y-auto",
|
|
6
|
+
"uy:rounded-100 uy:border uy:border-solid uy:border-border-neutral uy:bg-surface-neutral uy:shadow-300"
|
|
7
|
+
] });
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as menuPopover };
|
|
@@ -1,14 +1,51 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
import { MenuProps as ReactAriaMenuProps } from 'react-aria-components/Menu';
|
|
3
|
-
interface
|
|
3
|
+
export interface MenuContentProps {
|
|
4
|
+
/** Sets a fixed width for the menu panel. */
|
|
4
5
|
width?: number;
|
|
5
|
-
/**
|
|
6
|
+
/** Adds custom classes to the menu panel. */
|
|
6
7
|
className?: string;
|
|
8
|
+
/** Controls whether items can be selected and which selection model to use. */
|
|
7
9
|
selectionMode?: ReactAriaMenuProps<object>['selectionMode'];
|
|
10
|
+
/** Controls the selected item keys for selection-enabled menus. */
|
|
8
11
|
selectedKeys?: ReactAriaMenuProps<object>['selectedKeys'];
|
|
12
|
+
/** Renders custom content when the menu has no items. */
|
|
13
|
+
renderEmptyState?: ReactNode | (() => ReactNode);
|
|
9
14
|
}
|
|
10
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Provides the keyboard-navigable list inside a `Menu` or `MenuSubmenu`.
|
|
17
|
+
*
|
|
18
|
+
* Use `MenuContent` for actions, links, sections, and custom empty states.
|
|
19
|
+
* The panel uses Unity's menu sizing by default and keeps item focus and
|
|
20
|
+
* selection semantics provided by React Aria.
|
|
21
|
+
* @param props - Menu items, sizing, selection, and empty-state content.
|
|
22
|
+
* @param props.children - `RawMenuItem`, `MenuSection`, `MenuSeparator`, or
|
|
23
|
+
* `MenuSubmenu` elements.
|
|
24
|
+
* @param props.width - Sets a fixed panel width in pixels.
|
|
25
|
+
* @param props.className - Adds custom classes to the menu panel.
|
|
26
|
+
* @param props.selectionMode - Enables single or multiple item selection.
|
|
27
|
+
* @param props.selectedKeys - Controls the selected item keys.
|
|
28
|
+
* @param props.renderEmptyState - Renders when the menu contains no items.
|
|
29
|
+
* @see {@link MenuContentProps} for all available props.
|
|
30
|
+
* @see {@link RawMenuItem} for the standard item composition.
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import {
|
|
34
|
+
* MenuContent,
|
|
35
|
+
* RawMenuItem,
|
|
36
|
+
* } from '@payfit/unity-components'
|
|
37
|
+
*
|
|
38
|
+
* <MenuContent>
|
|
39
|
+
* <RawMenuItem>Cut</RawMenuItem>
|
|
40
|
+
* <RawMenuItem>Copy</RawMenuItem>
|
|
41
|
+
* </MenuContent>
|
|
42
|
+
* ```
|
|
43
|
+
* @remarks
|
|
44
|
+
* The default panel width is at least 192px and at most 384px, including when
|
|
45
|
+
* the menu renders an empty state. Pass `renderEmptyState` when the menu can
|
|
46
|
+
* legitimately have no actions.
|
|
47
|
+
*/
|
|
48
|
+
export declare function MenuContent({ children, width, className, selectionMode, selectedKeys, renderEmptyState, }: PropsWithChildren<MenuContentProps>): import('react/jsx-runtime').JSX.Element;
|
|
11
49
|
export declare namespace MenuContent {
|
|
12
50
|
var displayName: string;
|
|
13
51
|
}
|
|
14
|
-
export {};
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
import { useMenuContext as e } from "../Menu.context.js";
|
|
1
2
|
import "react";
|
|
2
|
-
import { uyMerge as
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { Menu as
|
|
3
|
+
import { uyMerge as t, uyTv as n } from "@payfit/unity-themes";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
import { Menu as i } from "react-aria-components/Menu";
|
|
5
6
|
//#region src/core/components/menu/parts/MenuContent.tsx
|
|
6
|
-
var
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
var a = n({ base: ["uy:outline-none", "uy:w-(--uy-menu-content-width) uy:min-w-(--uy-menu-content-min-width) uy:max-w-(--uy-menu-content-max-width)"] });
|
|
8
|
+
function o({ children: n, width: o, className: s, selectionMode: c, selectedKeys: l, renderEmptyState: u }) {
|
|
9
|
+
let { compact: d } = e(), f = typeof u == "function" ? u : u === void 0 ? void 0 : () => u;
|
|
10
|
+
return /* @__PURE__ */ r(i, {
|
|
11
|
+
className: t(a(), s),
|
|
12
|
+
selectionMode: c,
|
|
13
|
+
selectedKeys: l,
|
|
14
|
+
renderEmptyState: f,
|
|
15
|
+
"data-compact": d,
|
|
12
16
|
style: {
|
|
13
|
-
"--uy-menu-content-width":
|
|
14
|
-
"--uy-menu-content-min-width":
|
|
17
|
+
"--uy-menu-content-width": o ? `${o}px` : "auto",
|
|
18
|
+
"--uy-menu-content-min-width": o ? "0px" : "calc(var(--uy-spacing) * 24)",
|
|
19
|
+
"--uy-menu-content-max-width": o ? `${o}px` : "calc(var(--uy-spacing) * 48)"
|
|
15
20
|
},
|
|
16
|
-
children:
|
|
21
|
+
children: n
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
|
-
|
|
24
|
+
o.displayName = "MenuContent";
|
|
20
25
|
//#endregion
|
|
21
|
-
export {
|
|
26
|
+
export { o as MenuContent };
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
interface MenuHeaderProps {
|
|
2
|
+
export interface MenuHeaderProps {
|
|
3
|
+
/** Adds classes to the header element. */
|
|
3
4
|
className?: string;
|
|
4
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Adds a non-interactive heading above a group of menu items.
|
|
8
|
+
*
|
|
9
|
+
* Use `MenuHeader` for contextual text that is not a selectable section
|
|
10
|
+
* heading. Use `MenuSection` when the heading labels a semantic group of
|
|
11
|
+
* actions.
|
|
12
|
+
* @param props - Header content and optional classes.
|
|
13
|
+
* @param props.children - The non-interactive heading content.
|
|
14
|
+
* @param props.className - Adds classes to the header element.
|
|
15
|
+
*/
|
|
5
16
|
export declare function MenuHeader({ children, className, }: PropsWithChildren<MenuHeaderProps>): import('react/jsx-runtime').JSX.Element;
|
|
6
17
|
export declare namespace MenuHeader {
|
|
7
18
|
var displayName: string;
|
|
8
19
|
}
|
|
9
|
-
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { useMenuContext as e } from "../Menu.context.js";
|
|
2
|
+
import { MenuSeparator as t } from "./MenuSeparator.js";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { MenuSection as i } from "react-aria-components/Menu";
|
|
5
|
+
import { Header as a } from "react-aria-components/Header";
|
|
5
6
|
//#region src/core/components/menu/parts/MenuHeader.tsx
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function o({ children: o, className: s }) {
|
|
8
|
+
let { compact: c } = e();
|
|
9
|
+
return /* @__PURE__ */ r(i, { children: [/* @__PURE__ */ n(a, {
|
|
10
|
+
className: `uy:px-100 ${c ? "uy:py-50" : "uy:py-100"} ${s ?? ""}`,
|
|
11
|
+
children: o
|
|
12
|
+
}), /* @__PURE__ */ n(t, {})] });
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
o.displayName = "MenuHeader";
|
|
13
15
|
//#endregion
|
|
14
|
-
export {
|
|
16
|
+
export { o as MenuHeader };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuSectionProps as AriaMenuSectionProps } from 'react-aria-components/Menu';
|
|
2
|
-
interface MenuSectionProps<TItemType extends object> extends AriaMenuSectionProps<TItemType> {
|
|
2
|
+
export interface MenuSectionProps<TItemType extends object> extends AriaMenuSectionProps<TItemType> {
|
|
3
3
|
/**
|
|
4
4
|
* The label rendered above the section's items.
|
|
5
5
|
* Always present in the DOM for accessibility; use `isTitleHidden` to hide it visually.
|
|
@@ -10,13 +10,20 @@ interface MenuSectionProps<TItemType extends object> extends AriaMenuSectionProp
|
|
|
10
10
|
* @default false
|
|
11
11
|
*/
|
|
12
12
|
isTitleHidden?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Adds a separator after the section.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
withDivider?: boolean;
|
|
18
|
+
/** Adds classes to the section root. */
|
|
13
19
|
className?: string;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* `MenuSection` groups related menu items under a labelled heading inside a `MenuContent` panel.
|
|
17
23
|
* The section title provides both visual context and an accessible label for assistive technologies.
|
|
18
24
|
* Use multiple `MenuSection` blocks separated by `MenuSeparator` to divide a menu into distinct
|
|
19
|
-
* named categories.
|
|
25
|
+
* named categories. Set `compact` on the parent `Menu` to use the compact
|
|
26
|
+
* spacing for the section and its items.
|
|
20
27
|
*
|
|
21
28
|
* For collection-based rendering pass an `items` array and a render function as children.
|
|
22
29
|
* For static content pass `RawMenuItem` elements directly as children.
|
|
@@ -75,8 +82,7 @@ interface MenuSectionProps<TItemType extends object> extends AriaMenuSectionProp
|
|
|
75
82
|
* visually distinct groups within a single menu
|
|
76
83
|
* @see {@link https://github.com/PayFit/hr-apps/blob/master/libs/shared/unity/components/src/core/components/menu/parts/MenuSection.tsx Source code on GitHub}
|
|
77
84
|
*/
|
|
78
|
-
export declare function MenuSection<TItemType extends object>({ children, items, className, title, isTitleHidden, ...rest }: MenuSectionProps<TItemType>): import('react/jsx-runtime').JSX.Element;
|
|
85
|
+
export declare function MenuSection<TItemType extends object>({ children, items, className, title, isTitleHidden, withDivider, ...rest }: MenuSectionProps<TItemType>): import('react/jsx-runtime').JSX.Element;
|
|
79
86
|
export declare namespace MenuSection {
|
|
80
87
|
var displayName: string;
|
|
81
88
|
}
|
|
82
|
-
export {};
|
|
@@ -1,34 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { useMenuContext as e } from "../Menu.context.js";
|
|
2
|
+
import { MenuSeparator as t } from "./MenuSeparator.js";
|
|
3
|
+
import { uyTv as n } from "@payfit/unity-themes";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
import { MenuSection as a } from "react-aria-components/Menu";
|
|
6
|
+
import { Header as o } from "react-aria-components/Header";
|
|
7
|
+
import { Collection as s } from "react-aria-components/Collection";
|
|
6
8
|
//#region src/core/components/menu/parts/MenuSection.tsx
|
|
7
|
-
var
|
|
9
|
+
var c = n({
|
|
8
10
|
slots: {
|
|
9
|
-
base: [""],
|
|
10
|
-
header: ["uy:px-150 uy:py-100 uy:typography-body-strong uy:text-content-neutral-enabled"]
|
|
11
|
+
base: ["uy:group/menu-section uy:w-full"],
|
|
12
|
+
header: ["uy:w-full uy:overflow-clip uy:px-150 uy:py-125 uy:sm:py-100 uy:typography-body-strong uy:text-content-neutral-enabled"]
|
|
11
13
|
},
|
|
12
|
-
variants: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
variants: {
|
|
15
|
+
compact: {
|
|
16
|
+
true: { header: "uy:px-100 uy:py-100 uy:sm:py-50" },
|
|
17
|
+
false: { header: "" }
|
|
18
|
+
},
|
|
19
|
+
isTitleHidden: {
|
|
20
|
+
true: { header: "uy:sr-only" },
|
|
21
|
+
false: { header: "" }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
compact: !1,
|
|
26
|
+
isTitleHidden: !1
|
|
27
|
+
}
|
|
17
28
|
});
|
|
18
|
-
function
|
|
19
|
-
let { base:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
function l({ children: n, items: l, className: u, title: d, isTitleHidden: f, withDivider: p = !1, ...m }) {
|
|
30
|
+
let { compact: h } = e(), { base: g, header: _ } = c({
|
|
31
|
+
isTitleHidden: f,
|
|
32
|
+
compact: h
|
|
33
|
+
});
|
|
34
|
+
return /* @__PURE__ */ i(a, {
|
|
35
|
+
...m,
|
|
36
|
+
"data-compact": h || void 0,
|
|
37
|
+
className: g({ className: u }),
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ r(o, {
|
|
40
|
+
className: _(),
|
|
41
|
+
children: d
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ r(s, {
|
|
44
|
+
items: l,
|
|
45
|
+
children: n
|
|
46
|
+
}),
|
|
47
|
+
p && /* @__PURE__ */ r(t, {})
|
|
48
|
+
]
|
|
30
49
|
});
|
|
31
50
|
}
|
|
32
|
-
|
|
51
|
+
l.displayName = "MenuSection";
|
|
33
52
|
//#endregion
|
|
34
|
-
export {
|
|
53
|
+
export { l as MenuSection };
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separates related groups of actions inside a `MenuContent` panel.
|
|
3
|
+
*
|
|
4
|
+
* Use `MenuSeparator` between item groups when spacing alone would not make
|
|
5
|
+
* the menu's categories clear.
|
|
6
|
+
*/
|
|
1
7
|
export declare function MenuSeparator(): import('react/jsx-runtime').JSX.Element;
|
|
2
8
|
export declare namespace MenuSeparator {
|
|
3
9
|
var displayName: string;
|
|
@@ -2,7 +2,7 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import { Separator as t } from "react-aria-components/Separator";
|
|
3
3
|
//#region src/core/components/menu/parts/MenuSeparator.tsx
|
|
4
4
|
function n() {
|
|
5
|
-
return /* @__PURE__ */ e(t, { className: "uy:h-[1px] uy:bg-
|
|
5
|
+
return /* @__PURE__ */ e(t, { className: "uy:h-[1px] uy:bg-border-neutral uy:w-full uy:mt-100 uy:mb-100" });
|
|
6
6
|
}
|
|
7
7
|
n.displayName = "MenuSeparator";
|
|
8
8
|
//#endregion
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { SubmenuTriggerProps as AriaSubmenuTriggerProps } from 'react-aria-components/Menu';
|
|
3
|
+
export interface MenuSubmenuProps extends Omit<AriaSubmenuTriggerProps, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* The submenu trigger item followed by its menu content.
|
|
6
|
+
*/
|
|
7
|
+
children: [ReactElement, ReactElement];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Adds a keyboard-accessible nested menu to a `MenuContent` panel.
|
|
11
|
+
*
|
|
12
|
+
* Use `MenuSubmenu` when an action needs a second level of choices. React Aria
|
|
13
|
+
* manages focus, pointer interaction, arrow-key navigation, and `Escape`
|
|
14
|
+
* dismissal; Unity adds the submenu caret to the trigger item automatically.
|
|
15
|
+
* @param props - React Aria submenu behavior and the two-part composition.
|
|
16
|
+
* @param props.children - Exactly two children: the trigger `RawMenuItem`,
|
|
17
|
+
* followed by its `MenuContent`.
|
|
18
|
+
* @see {@link MenuSubmenuProps} for all available props.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import {
|
|
22
|
+
* MenuContent,
|
|
23
|
+
* MenuSubmenu,
|
|
24
|
+
* RawMenuItem,
|
|
25
|
+
* } from '@payfit/unity-components'
|
|
26
|
+
*
|
|
27
|
+
* <MenuContent>
|
|
28
|
+
* <MenuSubmenu>
|
|
29
|
+
* <RawMenuItem>Share</RawMenuItem>
|
|
30
|
+
* <MenuContent>
|
|
31
|
+
* <RawMenuItem>SMS</RawMenuItem>
|
|
32
|
+
* <RawMenuItem>Email</RawMenuItem>
|
|
33
|
+
* </MenuContent>
|
|
34
|
+
* </MenuSubmenu>
|
|
35
|
+
* </MenuContent>
|
|
36
|
+
* ```
|
|
37
|
+
* @remarks
|
|
38
|
+
* Nest another `MenuSubmenu` inside the child `MenuContent` to create deeper
|
|
39
|
+
* levels. Add a `suffix` to the trigger item when it also needs a badge or
|
|
40
|
+
* other trailing content; Unity displays it before the submenu caret.
|
|
41
|
+
*/
|
|
42
|
+
export declare function MenuSubmenu({ children, ...rest }: MenuSubmenuProps): ReactElement;
|
|
43
|
+
export declare namespace MenuSubmenu {
|
|
44
|
+
var displayName: string;
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { menuPopover as e } from "../menu.variants.js";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { Popover as i, SubmenuTrigger as a } from "react-aria-components/Menu";
|
|
5
|
+
//#region src/core/components/menu/parts/MenuSubmenu.tsx
|
|
6
|
+
function o({ children: o, ...s }) {
|
|
7
|
+
let [c, l] = t.Children.toArray(o);
|
|
8
|
+
if (!c || !l) throw Error("MenuSubmenu must have a trigger and a menu content");
|
|
9
|
+
return /* @__PURE__ */ r(a, {
|
|
10
|
+
...s,
|
|
11
|
+
children: [c, /* @__PURE__ */ n(i, {
|
|
12
|
+
offset: -8,
|
|
13
|
+
crossOffset: -8,
|
|
14
|
+
className: e(),
|
|
15
|
+
"data-dd-privacy": "allow",
|
|
16
|
+
children: l
|
|
17
|
+
})]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
o.displayName = "MenuSubmenu";
|
|
21
|
+
//#endregion
|
|
22
|
+
export { o as MenuSubmenu };
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
interface MenuTriggerProps {
|
|
2
|
+
export interface MenuTriggerProps {
|
|
3
|
+
/** Adds classes to the trigger element. */
|
|
3
4
|
className?: string;
|
|
5
|
+
/** Renders the provided child as the trigger without an extra button. */
|
|
4
6
|
asChild?: boolean;
|
|
5
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders the control that opens a `Menu`.
|
|
10
|
+
*
|
|
11
|
+
* Use a text child for the default Unity trigger or set `asChild` to compose
|
|
12
|
+
* an existing Unity button or icon button without introducing a second
|
|
13
|
+
* interactive element.
|
|
14
|
+
* @param props - Trigger content and composition options.
|
|
15
|
+
* @param props.children - The text or control that opens the menu.
|
|
16
|
+
* @param props.asChild - Renders the child directly as the trigger element.
|
|
17
|
+
* @param props.className - Adds classes to the trigger element.
|
|
18
|
+
* @see {@link Menu} for the complete menu composition.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { IconButton, MenuTrigger } from '@payfit/unity-components'
|
|
22
|
+
*
|
|
23
|
+
* <MenuTrigger asChild>
|
|
24
|
+
* <IconButton icon="DotsThreeOutlined" label="More actions" />
|
|
25
|
+
* </MenuTrigger>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
6
28
|
export declare function MenuTrigger({ children, asChild, className, }: PropsWithChildren<MenuTriggerProps>): import('react/jsx-runtime').JSX.Element;
|
|
7
29
|
export declare namespace MenuTrigger {
|
|
8
30
|
var displayName: string;
|
|
9
31
|
}
|
|
10
|
-
export {};
|
|
@@ -1,18 +1,61 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { MenuItemProps as MenuItemAriaComponentProps } from 'react-aria-components/Menu';
|
|
3
3
|
import { DataAttributes } from '../../../types/DataAttributes.js';
|
|
4
4
|
export interface MenuItemProps extends DataAttributes {
|
|
5
|
+
/** The visible label or a React Aria render function for the item. */
|
|
5
6
|
children?: MenuItemAriaComponentProps['children'];
|
|
7
|
+
/** Identifies the item in a collection or selection model. */
|
|
6
8
|
id?: MenuItemAriaComponentProps['id'];
|
|
9
|
+
/** Supplies the accessible text value and the browser title for truncated labels. */
|
|
7
10
|
textValue?: MenuItemAriaComponentProps['textValue'];
|
|
11
|
+
/** Truncates a string label to one line when it exceeds the available width. */
|
|
12
|
+
isTruncated?: boolean;
|
|
13
|
+
/** Turns the item into a navigation link. */
|
|
8
14
|
href?: MenuItemAriaComponentProps['href'];
|
|
9
15
|
target?: MenuItemAriaComponentProps['target'];
|
|
10
16
|
rel?: MenuItemAriaComponentProps['rel'];
|
|
17
|
+
/** Runs when the user activates the item. */
|
|
11
18
|
onAction?: MenuItemAriaComponentProps['onAction'];
|
|
19
|
+
/** Disables activation and removes the item from keyboard interaction. */
|
|
12
20
|
isDisabled?: MenuItemAriaComponentProps['isDisabled'];
|
|
21
|
+
/** Renders a fixed-size visual slot before the item content. */
|
|
13
22
|
prefix?: ReactNode;
|
|
23
|
+
/** Adds classes to the item root. */
|
|
14
24
|
className?: string;
|
|
25
|
+
/** Renders trailing content, such as a Unity `Badge`. */
|
|
26
|
+
suffix?: ReactNode;
|
|
15
27
|
}
|
|
16
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Renders one action or link in a keyboard-navigable Unity menu.
|
|
30
|
+
*
|
|
31
|
+
* Compose `RawMenuItem` inside `MenuContent` for standard menu actions. Use
|
|
32
|
+
* `prefix` for a leading icon and `suffix` for trailing content such as a
|
|
33
|
+
* badge. When the item opens a `MenuSubmenu`, Unity appends the submenu caret
|
|
34
|
+
* after the suffix.
|
|
35
|
+
* @param props - Item label, action, link, and optional visual slots.
|
|
36
|
+
* @param props.children - The visible label or a React Aria render function.
|
|
37
|
+
* @param props.prefix - A leading icon or custom React node.
|
|
38
|
+
* @param props.suffix - A trailing badge or custom React node.
|
|
39
|
+
* @param props.textValue - The full accessible text and browser title for a truncated label.
|
|
40
|
+
* @param props.isTruncated - Truncates a string label within the available item width and uses `textValue` as its browser title.
|
|
41
|
+
* @see {@link MenuItemProps} for all available props.
|
|
42
|
+
* @see {@link MenuSubmenu} for nested menu actions.
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* import { Badge, MenuContent, RawMenuItem } from '@payfit/unity-components'
|
|
46
|
+
*
|
|
47
|
+
* <MenuContent>
|
|
48
|
+
* <RawMenuItem suffix={<Badge variant="success">New</Badge>}>
|
|
49
|
+
* Import
|
|
50
|
+
* </RawMenuItem>
|
|
51
|
+
* </MenuContent>
|
|
52
|
+
* ```
|
|
53
|
+
* @remarks
|
|
54
|
+
* Set `isTruncated` to truncate a string label within the available item width.
|
|
55
|
+
* The native `title` attribute is taken directly from `textValue`, so provide
|
|
56
|
+
* the complete label there when the visual children are truncated or do not
|
|
57
|
+
* expose a plain text label to React Aria.
|
|
58
|
+
*/
|
|
59
|
+
export declare const RawMenuItem: React.ForwardRefExoticComponent<MenuItemProps & {
|
|
17
60
|
children?: ReactNode | undefined;
|
|
18
|
-
} &
|
|
61
|
+
} & React.RefAttributes<HTMLDivElement>>;
|