@vuu-ui/vuu-context-menu 4.0.0-alpha.2 → 4.0.0-alpha.21

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.0.0-alpha.2",
2
+ "version": "4.0.0-alpha.21",
3
3
  "author": "heswell",
4
4
  "main": "./src/index.js",
5
5
  "type": "module",
@@ -10,15 +10,15 @@
10
10
  "type-defs": "node ../../scripts/build-type-defs.mjs"
11
11
  },
12
12
  "devDependencies": {
13
- "@vuu-ui/vuu-data-types": "4.0.0-alpha.2",
14
- "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.2",
15
- "@vuu-ui/vuu-table-types": "4.0.0-alpha.2"
13
+ "@vuu-ui/vuu-data-types": "4.0.0-alpha.21",
14
+ "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.21",
15
+ "@vuu-ui/vuu-table-types": "4.0.0-alpha.21"
16
16
  },
17
17
  "dependencies": {
18
- "@vuu-ui/vuu-utils": "4.0.0-alpha.2",
19
- "@salt-ds/core": "1.67.0",
20
- "@salt-ds/styles": "0.2.1",
21
- "@salt-ds/window": "0.1.1"
18
+ "@vuu-ui/vuu-utils": "4.0.0-alpha.21",
19
+ "@salt-ds/core": "1.72.0",
20
+ "@salt-ds/styles": "0.4.1",
21
+ "@salt-ds/window": "0.1.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "clsx": "^2.0.0",
@@ -32,8 +32,9 @@
32
32
  ],
33
33
  "exports": {
34
34
  ".": {
35
+ "types": "./types/index.d.ts",
35
36
  "import": "./src/index.js",
36
- "types": "./types/index.d.ts"
37
+ "default": "./src/index.js"
37
38
  }
38
39
  },
39
40
  "module": "./src/index.js",
@@ -25,6 +25,10 @@ const css = `
25
25
  }
26
26
  }
27
27
 
28
+ .vuuContextMenuDivider {
29
+ margin: var(--salt-spacing-50) 0;
30
+ }
31
+
28
32
 
29
33
  `;
30
34
  export default css;
package/src/menu-utils.js CHANGED
@@ -1,10 +1,20 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Menu, MenuItem, MenuPanel, MenuTrigger } from "@salt-ds/core";
2
+ import { Divider, Menu, MenuItem, MenuPanel, MenuTrigger } from "@salt-ds/core";
3
+ import { Fragment } from "react";
3
4
  const isGroupMenuItemDescriptor = (menuItem)=>void 0 !== menuItem && "children" in menuItem;
4
5
  const isOpenBulkEditResponse = (rpcResponse)=>"beginEditSession" === rpcResponse.rpcName;
5
6
  const hasShowNotificationAction = (res)=>res.action?.type === "SHOW_NOTIFICATION_ACTION";
6
7
  const menuItemsFromMenuDescriptors = (menuDescriptors, menuActionHandler)=>{
7
- const fromDescriptor = (menuItem, index)=>isGroupMenuItemDescriptor(menuItem) ? /*#__PURE__*/ jsxs(Menu, {
8
+ const fromDescriptor = (menuItem, index)=>menuItem.dividerBefore ? /*#__PURE__*/ jsxs(Fragment, {
9
+ children: [
10
+ /*#__PURE__*/ jsx(Divider, {
11
+ "aria-hidden": true,
12
+ className: "vuuContextMenuDivider"
13
+ }),
14
+ itemFromDescriptor(menuItem, index)
15
+ ]
16
+ }, index) : itemFromDescriptor(menuItem, index);
17
+ const itemFromDescriptor = (menuItem, index)=>isGroupMenuItemDescriptor(menuItem) ? /*#__PURE__*/ jsxs(Menu, {
8
18
  children: [
9
19
  /*#__PURE__*/ jsx(MenuTrigger, {
10
20
  children: /*#__PURE__*/ jsx(MenuItem, {
@@ -19,6 +29,7 @@ const menuItemsFromMenuDescriptors = (menuDescriptors, menuActionHandler)=>{
19
29
  }, index) : /*#__PURE__*/ jsx(MenuItem, {
20
30
  className: menuItem.className,
21
31
  "data-icon": menuItem.icon,
32
+ disabled: menuItem.disabled,
22
33
  onClick: ()=>menuActionHandler(menuItem.id, menuItem.options),
23
34
  children: menuItem.label
24
35
  }, index);
@@ -7,4 +7,4 @@ export interface ContextMenuProps extends Pick<MenuProps, "open" | "onOpenChange
7
7
  x: number;
8
8
  y: number;
9
9
  }
10
- export declare const ContextMenu: ({ menuHandler, menuItemDescriptors, onOpenChange, open, x, y, }: ContextMenuProps) => import("react").JSX.Element;
10
+ export declare const ContextMenu: ({ menuHandler, menuItemDescriptors, onOpenChange, open, x, y, }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -13,4 +13,4 @@ export interface ContextMenuProviderProps<L extends string = string, O = unknown
13
13
  menuActionHandler?: MenuActionHandler;
14
14
  menuBuilder?: MenuBuilder<L, O>;
15
15
  }
16
- export declare const ContextMenuProvider: <L extends string = string, O = unknown>({ children, menuActionHandler, menuBuilder, }: ContextMenuProviderProps<L, O>) => import("react").JSX.Element;
16
+ export declare const ContextMenuProvider: <L extends string = string, O = unknown>({ children, menuActionHandler, menuBuilder, }: ContextMenuProviderProps<L, O>) => import("react/jsx-runtime").JSX.Element;
@@ -3,11 +3,14 @@ import type { ShowNotificationAction, VuuRpcResponse } from "@vuu-ui/vuu-protoco
3
3
  import { MenuActionHandler } from "./ContextMenuProvider";
4
4
  export interface ContextMenuItemBase {
5
5
  className?: string;
6
+ /** Renders a divider above the item, to separate groups of items. */
7
+ dividerBefore?: boolean;
6
8
  icon?: string;
7
9
  label: string;
8
10
  location?: string;
9
11
  }
10
12
  export interface ContextMenuLeafItemDescriptor extends ContextMenuItemBase {
13
+ disabled?: boolean;
11
14
  id: string;
12
15
  options?: unknown;
13
16
  }
@@ -18,4 +21,4 @@ export type ContextMenuItemDescriptor = ContextMenuLeafItemDescriptor | ContextM
18
21
  export declare const isGroupMenuItemDescriptor: (menuItem?: ContextMenuItemDescriptor) => menuItem is ContextMenuGroupItemDescriptor;
19
22
  export declare const isOpenBulkEditResponse: (rpcResponse: Partial<VuuRpcResponse>) => rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema>;
20
23
  export declare const hasShowNotificationAction: (res: Partial<VuuRpcResponse>) => res is MenuRpcResponse<ShowNotificationAction>;
21
- export declare const menuItemsFromMenuDescriptors: (menuDescriptors: ContextMenuItemDescriptor[], menuActionHandler: MenuActionHandler) => import("react").JSX.Element[];
24
+ export declare const menuItemsFromMenuDescriptors: (menuDescriptors: ContextMenuItemDescriptor[], menuActionHandler: MenuActionHandler) => import("react/jsx-runtime").JSX.Element[];