@payfit/unity-components 3.23.23 → 3.23.25
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/bottom-sheet/BottomSheet.d.ts +7 -6
- package/dist/esm/core/components/bottom-sheet/BottomSheet.js +27 -22
- package/dist/esm/core/components/bottom-sheet/parts/BottomSheetDragIndicator.js +3 -3
- 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/components/side-panel/parts/SidePanelDragIndicator.js +3 -3
- package/dist/esm/core/index.d.ts +1 -0
- package/dist/esm/core/index.js +182 -181
- package/dist/esm/index.js +195 -194
- package/package.json +6 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { VariantProps } from '@payfit/unity-themes';
|
|
2
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { VariantProps } from '@payfit/unity-themes';
|
|
3
|
+
import { SheetProps, SheetTrigger } from 'react-aria-components/Sheet';
|
|
3
4
|
export declare const bottomSheet: import('tailwind-variants').TVReturnType<{
|
|
4
5
|
[key: string]: {
|
|
5
6
|
[key: string]: import('tailwind-variants').ClassValue | {
|
|
@@ -37,7 +38,7 @@ export declare const bottomSheet: import('tailwind-variants').TVReturnType<{
|
|
|
37
38
|
wrapper: string[];
|
|
38
39
|
content: string[];
|
|
39
40
|
}>>;
|
|
40
|
-
export interface BottomSheetProps extends PropsWithChildren<VariantProps<typeof bottomSheet
|
|
41
|
+
export interface BottomSheetProps extends PropsWithChildren<VariantProps<typeof bottomSheet>>, Omit<SheetProps, 'className' | 'style' | 'children'> {
|
|
41
42
|
/**
|
|
42
43
|
* Controls whether the sheet can be dismissed by clicking outside or using escape key.
|
|
43
44
|
* @default true
|
|
@@ -86,13 +87,13 @@ export interface BottomSheetProps extends PropsWithChildren<VariantProps<typeof
|
|
|
86
87
|
* BottomSheetContent,
|
|
87
88
|
* BottomSheetFooter,
|
|
88
89
|
* Button,
|
|
89
|
-
*
|
|
90
|
+
* SheetTrigger
|
|
90
91
|
* } from '@payfit/unity-components'
|
|
91
92
|
*
|
|
92
93
|
* // Uncontrolled example
|
|
93
94
|
* function BasicExample() {
|
|
94
95
|
* return (
|
|
95
|
-
* <
|
|
96
|
+
* <SheetTrigger>
|
|
96
97
|
* <Button>Open bottom sheet</Button>
|
|
97
98
|
* <BottomSheet>
|
|
98
99
|
* <BottomSheetHeader>Sheet title</BottomSheetHeader>
|
|
@@ -102,7 +103,7 @@ export interface BottomSheetProps extends PropsWithChildren<VariantProps<typeof
|
|
|
102
103
|
* <Button variant="primary">Save</Button>
|
|
103
104
|
* </BottomSheetFooter>
|
|
104
105
|
* </BottomSheet>
|
|
105
|
-
* </
|
|
106
|
+
* </SheetTrigger>
|
|
106
107
|
* )
|
|
107
108
|
* }
|
|
108
109
|
*
|
|
@@ -134,4 +135,4 @@ export interface BottomSheetProps extends PropsWithChildren<VariantProps<typeof
|
|
|
134
135
|
* [API Docs](https://unity-components.payfit.io/?path=/docs/feedback-bottomsheet--docs)
|
|
135
136
|
*/
|
|
136
137
|
declare const BottomSheet: import('react').ForwardRefExoticComponent<BottomSheetProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
137
|
-
export { BottomSheet };
|
|
138
|
+
export { BottomSheet, SheetTrigger };
|
|
@@ -2,10 +2,9 @@ import { BottomSheetDragIndicator as e } from "./parts/BottomSheetDragIndicator.
|
|
|
2
2
|
import { forwardRef as t } from "react";
|
|
3
3
|
import { uyTv as n } from "@payfit/unity-themes";
|
|
4
4
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import { Modal as o, ModalOverlay as s } from "react-aria-components/Modal";
|
|
5
|
+
import { Sheet as a, SheetBackdrop as o, SheetContent as s, SheetOverlay as c, SheetTrigger as l } from "react-aria-components/Sheet";
|
|
7
6
|
//#region src/core/components/bottom-sheet/BottomSheet.tsx
|
|
8
|
-
var
|
|
7
|
+
var u = n({ slots: {
|
|
9
8
|
overlay: [
|
|
10
9
|
"uy:fixed uy:inset-0 uy:z-30 uy:overflow-y-auto",
|
|
11
10
|
"uy:backdrop-blur-sm uy:bg-utility-backdrop/65",
|
|
@@ -21,28 +20,34 @@ var c = n({ slots: {
|
|
|
21
20
|
"uy:data-[entering]:animate-slide-up-fade-in uy:data-[exiting]:animate-slide-down-fade-out"
|
|
22
21
|
],
|
|
23
22
|
content: ["uy:flex uy:flex-col uy:h-full uy:min-h-[40svh] uy:overflow-hidden uy:outline-none"]
|
|
24
|
-
} }),
|
|
25
|
-
let { overlay:
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
23
|
+
} }), d = t(({ children: t, isOpen: n, onOpenChange: l, defaultOpen: d, isDismissable: f = !0, isKeyboardDismissDisabled: p = !1, ...m }, h) => {
|
|
24
|
+
let { overlay: g, wrapper: _, content: v } = u();
|
|
25
|
+
return /* @__PURE__ */ i(c, {
|
|
26
|
+
"data-unity-component": "BottomSheet",
|
|
27
|
+
className: g(),
|
|
28
28
|
isOpen: n,
|
|
29
29
|
onOpenChange: l,
|
|
30
|
-
defaultOpen:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
defaultOpen: d,
|
|
31
|
+
preventDismissal: !f,
|
|
32
|
+
children: [/* @__PURE__ */ r(o, {}), /* @__PURE__ */ r("div", {
|
|
33
|
+
className: "uy:contents",
|
|
34
|
+
onKeyDownCapture: (e) => {
|
|
35
|
+
!p || e.key !== "Escape" || (e.preventDefault(), e.stopPropagation());
|
|
36
|
+
},
|
|
37
|
+
children: /* @__PURE__ */ i(a, {
|
|
38
|
+
"data-dd-privacy": "allow",
|
|
39
|
+
...m,
|
|
40
|
+
ref: h,
|
|
40
41
|
className: _(),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
"data-unity-bottom-sheet": !0,
|
|
43
|
+
children: [/* @__PURE__ */ r(e, {}), /* @__PURE__ */ r(s, {
|
|
44
|
+
className: v(),
|
|
45
|
+
children: t
|
|
46
|
+
})]
|
|
47
|
+
})
|
|
48
|
+
})]
|
|
44
49
|
});
|
|
45
50
|
});
|
|
46
|
-
|
|
51
|
+
d.displayName = "BottomSheet";
|
|
47
52
|
//#endregion
|
|
48
|
-
export {
|
|
53
|
+
export { d as BottomSheet, l as SheetTrigger, u as bottomSheet };
|
|
@@ -2,15 +2,15 @@ import { useBreakpointListener as e } from "../../../hooks/use-breakpoint-listen
|
|
|
2
2
|
import { useContext as t, useRef as n } from "react";
|
|
3
3
|
import { uyTv as r } from "@payfit/unity-themes";
|
|
4
4
|
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useDrag as a } from "@use-gesture/react";
|
|
6
|
+
import { OverlayTriggerStateContext as o } from "react-aria-components/Dialog";
|
|
7
7
|
//#region src/core/components/bottom-sheet/parts/BottomSheetDragIndicator.tsx
|
|
8
8
|
var s = r({ slots: {
|
|
9
9
|
base: ["uy:md:hidden uy:mx-auto uy:py-100 uy:w-500", "uy:cursor-grab uy:touch-action-none"],
|
|
10
10
|
indicator: "uy:h-50 uy:rounded-pill uy:bg-content-neutral-lowest"
|
|
11
11
|
} }), c = 100;
|
|
12
12
|
function l() {
|
|
13
|
-
let r = n(null), l = t(
|
|
13
|
+
let r = n(null), l = t(o), u = e(), { base: d, indicator: f } = s(), p = u === "xs" || u === "sm", m = a((e) => {
|
|
14
14
|
let { movement: [t, n], direction: [i, a], intentional: o, cancel: s, last: u, event: d } = e;
|
|
15
15
|
if (!p) {
|
|
16
16
|
s();
|
|
@@ -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
|
+
}
|