@lumx/core 4.17.0-next.1 → 4.17.0-next.2
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.
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import type { JSXElement, LumxClassName } from '../../types';
|
|
2
|
+
export type MenuButtonVariant = 'button' | 'icon-button' | 'chip' | 'link';
|
|
3
|
+
/** ARIA keys set by MenuButton on the trigger — omitted from variant component props. */
|
|
4
|
+
type MenuButtonAriaKeys = 'aria-haspopup' | 'aria-controls' | 'aria-expanded';
|
|
5
|
+
/** Per-variant keys internally managed by MenuButton — omitted from variant component props. */
|
|
6
|
+
type MenuButtonVariantsInternalKeys = {
|
|
7
|
+
button: MenuButtonAriaKeys;
|
|
8
|
+
'icon-button': MenuButtonAriaKeys;
|
|
9
|
+
chip: MenuButtonAriaKeys | 'isClickable';
|
|
10
|
+
link: MenuButtonAriaKeys | 'href' | 'linkAs';
|
|
11
|
+
};
|
|
12
|
+
/** Discriminated union of MenuButton props across all trigger variants. */
|
|
13
|
+
export type MenuButtonVariantsProps<TBase, TVariantProps extends Record<MenuButtonVariant, any>> = {
|
|
14
|
+
[V in MenuButtonVariant]: TBase & (V extends 'button' ? {
|
|
15
|
+
variant?: V;
|
|
16
|
+
} : {
|
|
17
|
+
variant: V;
|
|
18
|
+
}) & Omit<TVariantProps[V], MenuButtonVariantsInternalKeys[V] | keyof TBase>;
|
|
19
|
+
}[MenuButtonVariant];
|
|
2
20
|
export interface MenuButtonProps {
|
|
21
|
+
variant?: MenuButtonVariant;
|
|
3
22
|
label?: JSXElement;
|
|
4
23
|
children?: JSXElement;
|
|
5
24
|
triggerProps?: Record<string, any>;
|
|
@@ -7,9 +26,13 @@ export interface MenuButtonProps {
|
|
|
7
26
|
onOpen?: (isOpen: boolean) => void;
|
|
8
27
|
}
|
|
9
28
|
export interface MenuButtonComponents {
|
|
10
|
-
|
|
29
|
+
MenuProvider: any;
|
|
30
|
+
MenuTrigger: any;
|
|
31
|
+
MenuPopover: any;
|
|
32
|
+
MenuList: any;
|
|
11
33
|
}
|
|
12
34
|
export declare const COMPONENT_NAME = "MenuButton";
|
|
13
35
|
export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
|
|
14
36
|
/** Menu button core template (composition of menu provider, trigger, popover and list) */
|
|
15
|
-
export declare const MenuButton: (props: MenuButtonProps, {
|
|
37
|
+
export declare const MenuButton: (props: MenuButtonProps, { MenuProvider, MenuTrigger, MenuPopover, MenuList }: MenuButtonComponents) => import("react").JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SetupStoriesOptions } from '@lumx/core/stories/types';
|
|
2
|
-
export declare function setup({ components: { MenuButton, MenuItem, MenuDivider }, }: SetupStoriesOptions<{
|
|
2
|
+
export declare function setup({ components: { MenuButton, MenuItem, MenuDivider }, decorators: { withCombinations }, }: SetupStoriesOptions<{
|
|
3
3
|
components: {
|
|
4
4
|
MenuButton: any;
|
|
5
5
|
MenuItem: any;
|
|
6
6
|
MenuDivider: any;
|
|
7
7
|
};
|
|
8
|
+
decorators: 'withCombinations';
|
|
8
9
|
}>): {
|
|
9
10
|
meta: {
|
|
10
11
|
component: any;
|
|
@@ -20,22 +21,30 @@ export declare function setup({ components: { MenuButton, MenuItem, MenuDivider
|
|
|
20
21
|
};
|
|
21
22
|
Default: {
|
|
22
23
|
argTypes: {
|
|
23
|
-
|
|
24
|
+
onItemClick: {
|
|
24
25
|
action: boolean;
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
};
|
|
28
|
+
render: ({ onItemClick, ...args }: any) => import("react").JSX.Element;
|
|
29
|
+
};
|
|
30
|
+
Variants: {
|
|
31
|
+
argTypes: {
|
|
32
|
+
onItemClick: {
|
|
30
33
|
action: boolean;
|
|
31
34
|
};
|
|
32
|
-
|
|
35
|
+
};
|
|
36
|
+
decorators: ((story: any, context: any) => any)[];
|
|
37
|
+
render: (args: any) => () => import("react").JSX.Element;
|
|
38
|
+
};
|
|
39
|
+
WithLinkItems: {
|
|
40
|
+
argTypes: {
|
|
41
|
+
onItemClick: {
|
|
33
42
|
action: boolean;
|
|
34
43
|
};
|
|
35
44
|
};
|
|
36
45
|
args: {
|
|
46
|
+
label: string;
|
|
37
47
|
emphasis: string;
|
|
38
48
|
};
|
|
39
|
-
render: ({ onProfile, onSettings, onHelp, onLogout, ...args }: any) => import("react").JSX.Element;
|
|
40
49
|
};
|
|
41
50
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type RenderResult = {
|
|
2
2
|
unmount: () => void;
|
|
3
|
-
container:
|
|
3
|
+
container: Element;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
6
|
* Options to set up the MenuButton test suite.
|
|
@@ -12,11 +12,23 @@ export interface MenuButtonTestSetup {
|
|
|
12
12
|
MenuItem: any;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Render a MenuButton template
|
|
15
|
+
* Render a MenuButton template, forwarding optional framework-specific render options
|
|
16
|
+
* (e.g. `{ wrapper }` in React, `{ global }` in Vue).
|
|
16
17
|
*
|
|
17
18
|
* @param template JSX render function returning the element to render.
|
|
19
|
+
* @param options Framework-specific render options (e.g. wrapper component).
|
|
18
20
|
*/
|
|
19
|
-
render: (template: () => any) => RenderResult;
|
|
21
|
+
render: (template: () => any, options?: Record<string, any>) => RenderResult;
|
|
20
22
|
}
|
|
21
|
-
export default function menuButtonTests({ components, render }: MenuButtonTestSetup):
|
|
23
|
+
export default function menuButtonTests({ components, render }: MenuButtonTestSetup): {
|
|
24
|
+
setup: (propsOverride?: Record<string, any>, options?: Record<string, any>) => {
|
|
25
|
+
props: {
|
|
26
|
+
label: string;
|
|
27
|
+
};
|
|
28
|
+
container: Element;
|
|
29
|
+
element: HTMLElement;
|
|
30
|
+
trigger: HTMLElement;
|
|
31
|
+
};
|
|
32
|
+
triggerClassName: "lumx-menu-trigger";
|
|
33
|
+
};
|
|
22
34
|
export {};
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { HasClassName, JSXElement, LumxClassName } from '../../types';
|
|
2
|
+
import { PopoverProps } from '../Popover';
|
|
3
3
|
/** MenuPopover props. */
|
|
4
|
-
export interface MenuPopoverProps extends HasClassName {
|
|
4
|
+
export interface MenuPopoverProps extends HasClassName, Pick<PopoverProps, 'placement' | 'anchorRef' | 'isOpen' | 'handleClose'> {
|
|
5
5
|
/** Popover content (a `Menu`). */
|
|
6
6
|
children?: JSXElement;
|
|
7
|
-
/** Whether the popover is open. */
|
|
8
|
-
isOpen?: boolean;
|
|
9
|
-
/** Placement relative to the anchor. Defaults to `'bottom-start'`. */
|
|
10
|
-
placement?: Placement;
|
|
11
|
-
/** Reference to the anchor element. */
|
|
12
|
-
anchorRef?: CommonRef;
|
|
13
|
-
/** Callback invoked when the popover requests to close (click away, escape). */
|
|
14
|
-
handleClose?(): void;
|
|
15
|
-
/** Whether the popover should close when clicking outside. Default: true. */
|
|
16
|
-
closeOnClickAway?: boolean;
|
|
17
|
-
/** Whether the popover should close on Escape. Default: true. */
|
|
18
|
-
closeOnEscape?: boolean;
|
|
19
|
-
/** Whether to render in a portal. Default: false (avoid stacking-context surprises). */
|
|
20
|
-
usePortal?: boolean;
|
|
21
|
-
/** Whether to focus the anchor on close. Default: true. */
|
|
22
|
-
focusAnchorOnClose?: boolean;
|
|
23
7
|
}
|
|
24
8
|
/** Framework components injected by wrappers. */
|
|
25
9
|
export interface MenuPopoverComponents {
|
|
@@ -3,6 +3,8 @@ import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../t
|
|
|
3
3
|
export interface MenuTriggerProps extends HasClassName {
|
|
4
4
|
/** Content of the trigger (label / icon / etc.). */
|
|
5
5
|
children?: JSXElement;
|
|
6
|
+
/** The id of the trigger element. */
|
|
7
|
+
id?: string;
|
|
6
8
|
/** The id of the menu container (for `aria-controls`). */
|
|
7
9
|
menuId?: string;
|
|
8
10
|
/** Whether the menu is currently open. */
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@floating-ui/dom": "^1.7.5",
|
|
10
|
-
"@lumx/icons": "^4.17.0-next.
|
|
10
|
+
"@lumx/icons": "^4.17.0-next.2",
|
|
11
11
|
"classnames": "^2.3.2",
|
|
12
12
|
"focus-visible": "^5.0.2",
|
|
13
13
|
"lodash": "4.18.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
67
67
|
},
|
|
68
68
|
"sideEffects": false,
|
|
69
|
-
"version": "4.17.0-next.
|
|
69
|
+
"version": "4.17.0-next.2",
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
72
72
|
"@testing-library/dom": "^10.4.1",
|