@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
|
@@ -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>>;
|
|
@@ -1,34 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Icon as e } from "../../icon/Icon.js";
|
|
2
|
+
import { useMenuContext as t } from "../Menu.context.js";
|
|
3
|
+
import { forwardRef as n } from "react";
|
|
4
|
+
import { uyTv as r } from "@payfit/unity-themes";
|
|
5
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { MenuItem as s } from "react-aria-components/Menu";
|
|
5
7
|
//#region src/core/components/menu/parts/RawMenuItem.tsx
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
var c = r({
|
|
9
|
+
base: [
|
|
10
|
+
"uy:cursor-pointer uy:group",
|
|
11
|
+
"uy:flex uy:items-center uy:px-150 uy:py-125 uy:sm:py-100 uy:gap-100 uy:rounded-50 uy:typography-body uy:text-content-neutral",
|
|
12
|
+
"uy:data-[open=true]:bg-surface-neutral-active",
|
|
13
|
+
"uy:not-aria-disabled:data-[hovered=true]:bg-surface-neutral-hover",
|
|
14
|
+
"uy:not-aria-disabled:data-[pressed=true]:bg-surface-neutral-pressed",
|
|
15
|
+
"uy:active:bg-surface-neutral-active",
|
|
16
|
+
"uy:data-[focused=true]:not-data-[focus-visible=true]:outline-0 uy:data-[focus-visible=true]:outline-2 uy:data-[focus-visible=true]:outline-offset-2 uy:data-[focus-visible=true]:outline-utility-focus-ring",
|
|
17
|
+
"uy:aria-disabled:text-content-neutral-disabled uy:aria-disabled:cursor-not-allowed"
|
|
18
|
+
],
|
|
19
|
+
variants: { compact: {
|
|
20
|
+
true: "uy:px-100 uy:py-100 uy:sm:py-50",
|
|
21
|
+
false: ""
|
|
22
|
+
} },
|
|
23
|
+
defaultVariants: { compact: !1 }
|
|
24
|
+
}), l = n(function({ prefix: n, children: r, id: l, textValue: u, isTruncated: d = !1, href: f, target: p, rel: m, onAction: h, className: g, isDisabled: _, suffix: v, ...y }, b) {
|
|
25
|
+
let { compact: x } = t(), S = d ? u : void 0;
|
|
26
|
+
return /* @__PURE__ */ a(s, {
|
|
27
|
+
ref: b,
|
|
28
|
+
id: l,
|
|
29
|
+
textValue: u,
|
|
30
|
+
href: f,
|
|
31
|
+
target: p,
|
|
32
|
+
rel: m,
|
|
33
|
+
isDisabled: _,
|
|
34
|
+
onAction: h,
|
|
35
|
+
className: c({
|
|
36
|
+
compact: x,
|
|
37
|
+
className: g
|
|
38
|
+
}),
|
|
39
|
+
...y,
|
|
40
|
+
children: (t) => /* @__PURE__ */ o(i, { children: [
|
|
41
|
+
n != null && /* @__PURE__ */ a("div", {
|
|
42
|
+
"data-unity-slot": "MenuItem.prefix",
|
|
43
|
+
className: "uy:flex uy:size-300 uy:shrink-0 uy:items-center uy:justify-center uy:text-content-neutral-low uy:group-aria-disabled:text-content-neutral-disabled",
|
|
44
|
+
children: n
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ a("div", {
|
|
47
|
+
"data-unity-slot": "MenuItem.content",
|
|
48
|
+
className: "uy:min-w-0 uy:min-h-300 uy:flex-1 uy:typography-body",
|
|
49
|
+
title: S,
|
|
50
|
+
children: typeof r == "function" ? r(t) : typeof r == "string" ? /* @__PURE__ */ a("span", {
|
|
51
|
+
className: d ? "uy:block uy:truncate" : "uy:block",
|
|
52
|
+
children: r
|
|
53
|
+
}) : r
|
|
54
|
+
}),
|
|
55
|
+
v != null && v !== !1 && /* @__PURE__ */ a("div", {
|
|
56
|
+
"data-unity-slot": "MenuItem.suffix",
|
|
57
|
+
className: "uy:flex uy:shrink-0 uy:items-center uy:justify-center uy:text-content-neutral-low uy:group-aria-disabled:text-content-neutral-disabled",
|
|
58
|
+
children: v
|
|
59
|
+
}),
|
|
60
|
+
t.hasSubmenu && /* @__PURE__ */ a("div", {
|
|
61
|
+
"data-unity-slot": "MenuItem.disclosure",
|
|
62
|
+
className: "uy:flex uy:shrink-0 uy:items-center uy:justify-center uy:text-content-neutral-low uy:group-aria-disabled:text-content-neutral-disabled",
|
|
63
|
+
children: /* @__PURE__ */ a(e, {
|
|
64
|
+
src: "CaretRightOutlined",
|
|
65
|
+
role: "presentation",
|
|
66
|
+
size: 20,
|
|
67
|
+
color: t.isDisabled ? "content.neutral.disabled" : "content.neutral.low"
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
] })
|
|
30
71
|
});
|
|
31
72
|
});
|
|
32
|
-
|
|
73
|
+
l.displayName = "RawMenuItem";
|
|
33
74
|
//#endregion
|
|
34
|
-
export {
|
|
75
|
+
export { l as RawMenuItem };
|
|
@@ -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/side-panel/parts/SidePanelDragIndicator.tsx
|
|
8
8
|
var s = r({ slots: {
|
|
9
9
|
base: ["uy:md:hidden uy:mx-auto uy:pt-300 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();
|
package/dist/esm/core/index.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ export * from './components/menu/parts/MenuSection.js';
|
|
|
126
126
|
export * from './components/menu/parts/RawMenuItem.js';
|
|
127
127
|
export * from './components/menu/parts/MenuSeparator.js';
|
|
128
128
|
export * from './components/menu/parts/MenuTrigger.js';
|
|
129
|
+
export * from './components/menu/parts/MenuSubmenu.js';
|
|
129
130
|
export * from './components/multi-select/MultiSelect.js';
|
|
130
131
|
export * from './components/multi-select/parts/MultiSelectOptGroup.js';
|
|
131
132
|
export * from './components/multi-select/parts/MultiSelectOption.js';
|